I have a similar problem in VS 2008. I can compile the example code (VC_ContFreq_IntClk_SCXI1126) no problem from Visual Studio 2008.
However, when I create my own project in visual studio with the same #includes i get the same errors:
Compiling...
DTRTestNov2010.c
Linking...
DTRTestNov2010.obj: error LNK2019: unresoloved external symbol _DAQmxClearTask@4 reference in function _main
DTRTestNov2010.obj: error LNK2019: unresoloved external symbol _DAQmxStopTask@4 reference in function _main
and so on... for all other function calls I made.
i am not a pro at c-programming. Am I supposed to setup a 'linker' somehow?
Thanks!
Sean
Here is my c-code (which operates in matlab typically, but I think is spawning a memory leak, so i'd like to test it in native C)
#include <stdio.h>
#include <NIDAQmx.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(void)
{
int32 error=0;
TaskHandle masterTaskHandle=0;
TaskHandle slaveTaskHandle=0;
int32 read;
int32 fs=30000;
int32 samplesPerLoop=30000;
int32 channels=4;
int32 arrayLength;
float64 data[30000];
char errBuff[2048]={'\0'};
arrayLength = samplesPerLoop * channels;
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&masterTaskHandle));
DAQmxErrChk (DAQmxCreateTask("",&slaveTaskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(masterTaskHandle,"Dev1/ai0:3","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCreateAIVoltageChan(slaveTaskHandle,"Dev1/ai0:3","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(masterTaskHandle,"",fs,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,samplesPerLoop));
DAQmxErrChk (DAQmxCfgSampClkTiming(slaveTaskHandle,"",fs,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,samplesPerLoop));
DAQmxErrChk (DAQmxCfgInputBuffer(masterTaskHandle,samplesPerLoop*2));
DAQmxErrChk (DAQmxCfgInputBuffer(slaveTaskHandle,samplesPerLoop*2));
DAQmxErrChk (DAQmxExportSignal(masterTaskHandle,DAQmx_Val_StartTrigger,"RTSI0"));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(slaveTaskHandle,"RTSI0",DAQmx_Val_Rising));
DAQmxErrChk (DAQmxSetExportedSampClkTimebaseOutputTerm(masterTaskHandle,"/Dev1/RTSI8"));
DAQmxErrChk (DAQmxSetSampClkTimebaseSrc(slaveTaskHandle,"RTSI8"));
DAQmxErrChk (DAQmxSetExportedSyncPulseEventOutputTerm(masterTaskHandle,"/Dev1/RTSI9"));
DAQmxErrChk (DAQmxSetSyncPulseSrc(slaveTaskHandle,"RTSI9"));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(slaveTaskHandle));
DAQmxErrChk (DAQmxStartTask(masterTaskHandle));
/*********************************************/
// DAQmx Read Code
/*********************************************/
DAQmxErrChk (DAQmxReadAnalogF64(masterTaskHandle,samplesPerLoop,5.0,DAQmx_Val_GroupByChannel,data,samplesPerLoop,&read,NULL));
DAQmxErrChk (DAQmxReadAnalogF64(slaveTaskHandle,samplesPerLoop,5.0,DAQmx_Val_GroupByChannel,data,samplesPerLoop,&read,NULL));
printf("Acquired %d points\n",read);
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( masterTaskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(slaveTaskHandle);
DAQmxStopTask(masterTaskHandle);
DAQmxClearTask(slaveTaskHandle);
DAQmxClearTask(masterTaskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}