Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

CodeBlocks, C++, mingw-w64 compiler, Windows 10, Errors: Undefined reference to `DAQmxCreateTask' and others.

Hi, 

 

I wonder if anyone could help me. I'm programming a NI-DAQmx application in C++, using CodeBlocks WxWidgets.

I'm using a recent version of the mingw-w64 compiler and Windows 10.

 

When compiling, I'm getting the undefined reference errors to the DAQmx___ statements:

 

`DAQmxCreateTask',

'DAQmxClearTask',

'DAQmxCreateAIVoltageChan',

and others.

 

I have included NIDAQmx.h, NIDAQmx.lib files in the project. I've searched for a few days, and read posts around the problem, read about wrapper files, and hacks within NIDAQmx.h, but can't seem to find anything to help.

 

Code snippet:

 

 

 

#include "Incoming_Signals.h"
#include <math.h>
#include <limits>
#include "NIDAQmx.h"


int PxiError = 0;
TaskHandle	taskHandle=0;
float64		data[32];
char		errBuff[2048]={'\0'};
int32      	readstuff;

#define DAQmxErrChk(functionCall) if( DAQmxFailed(PxiError=(functionCall)) ) goto Error; else

double AnalogInputs(unsigned int t)
{
   // DAQmx Configure Code
	DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
	DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"PXI1Slot4/ai0:31","Voltage",DAQmx_Val_Cfg_Default, -10.0, 10.0, DAQmx_Val_Volts, NULL));

	// DAQmx Start Code
	DAQmxErrChk (DAQmxStartTask(taskHandle));

	// DAQmx Read Code

	//(TaskHandle taskHandle, int32 numSampsPerChan, float64 timeout, bool32 fillMode, float64 readArray[], uInt32 arraySizeInSamps, int32 *sampsPerChanRead, bool32 *reserved);
	DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,1,10.0,DAQmx_Val_GroupByChannel,data,32,&readstuff,NULL));

	//Error handling
    Error:
	if( DAQmxFailed(PxiError) )
		DAQmxGetExtendedErrorInfo(errBuff,2048);

	if( taskHandle!=0 ) {
		// DAQmx Stop Code
		DAQmxStopTask(taskHandle);
		DAQmxClearTask(taskHandle);
	}
}

 

 

 

 

Any advice would be appreciated, 

 

Thanks, 

 

Paul

Message 1 of 2
(2,458 Views)

Hi PaulJG,

 

Do you manage to solve your problem?

 

BR,

 

Maxime

0 Kudos
Message 2 of 2
(1,463 Views)