Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

Using Qt and NIDAQmx

I'm trying to use the modified NIDAQmx libraries posted by Vladimir from this thread:  to compile a simple example program from ANSI C examples that are included when LabView is installed.  I'm using the QT 4 development environment under WindowsXP 64.


My .pro file looks like this:


QT -= gui

TARGET = test

CONFIG += console

CONFIG -= app_bundle


SOURCES += main.cpp

LIBS += -Lu:/libs \




The u:\libs directory contains



Provided by vladimir.  My main.cpp files is basically just copied from the VoltUpdate example.  The only changes I've made are including


#include <QtCore/QCoreApplication>


and having the QCoreApplication object in the main function:


QCoreApplication a(argc,argv);



The problem will compile and "run" but when it runs it doesn't execute ANY of the code in main().  I know this because I've put breakpoints everywhere and it never reaches any of them.  I've encountered this error before and it usually occurs when there is some type of problem with linking libraries.



Any ideas?







0 Kudos
Message 1 of 4

Hi j1kleain,


You may be experiencing some issues because Windows XP 64 bit is not supported by DAQmx.  DAQmx supports XP 32 bit and Vista 64 bit. You might try this program on a computer with one of the supported opperating systems to make sure that it compiles and runs.  If the program compiles and runs, we can be sure that this is not working because of the unsupported opperating system.

Jim Schwartz
0 Kudos
Message 2 of 4

I am trying to interface a NI USB-6215 device with Qt 4.5.2 on a Mac Mini (Intel Core 2 Duo, Mac OS 10.5). I have installed the recommended (most-recent) version of the NI-DAQmx_Base (3.3.0). When I attempt to use the some of the code from the Examples/acquireNScans-DigRef.c, implemented as follows:




#include "NIDAQmxBase.h"

#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }

int myGenericClass::readDAQData()


p, li { white-space: pre-wrap; }

// Task parameters

int32 error = 0;

TaskHandle taskHandle = 0;

char errBuff[2048]={'\0'};

int32 i;


// Channel parameters

char chan[] = "Dev1/ai0";

float64 min = -10.0;

float64 max = 10.0;


// Timing parameters

char clockSource[] = "OnboardClock";

uInt64 samplesPerChan = 1000;

float64 sampleRate = 10000.0;


// Triggering parameters

char triggerSource[] = "PFI0";

uInt32 triggerSlope = DAQmx_Val_RisingSlope;

float64 triggerLevel = 1.0;


// Data read parameters

#define bufferSize (uInt32)1000

float64 data[bufferSize];

int32 pointsToRead = bufferSize;

int32 pointsRead;

float64 timeout = 10.0;



DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));

DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));

DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,samplesPerChan));

DAQmxErrChk (DAQmxBaseCfgAnlgEdgeStartTrig(taskHandle,triggerSource,triggerSlope,triggerLevel));

DAQmxErrChk (DAQmxBaseStartTask(taskHandle));

DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByChannel,data,bufferSize,&pointsRead,NULL));


qDebug() << "Acquired " << pointsRead << " samples";


// Just print out the first 10 points

for (i = 0; i < 10; ++i)

qDebug() << "data[" << i << "] = " << data[i];


if( DAQmxFailed(error) )


if(taskHandle != 0) {

DAQmxBaseStopTask (taskHandle);

DAQmxBaseClearTask (taskHandle);



if( DAQmxFailed(error) )

qDebug() << "DAQmxBase Error" << error << errBuff;

return 0;






I get this error at compile (aside from the uber helpful: collect2: ld returned 1 exit status):


/usr/bin/ld: Undefined symbols:












Obviously, all of these are getting called with error checking inside DAQmxErrChk. All of my #includes seem to be in order. Is there a library that I'm supposed to be linking to? Do I need to modify the NIDAQmxBase.h code that came with the NI-DAQmx_Base install?


Incidentally (though I doubt it's related to this problem, but just to thwart anyone asking), I have run the "lsdaq" (LabVIEW) script which successfully returns that the NI USB-6215 DAQ device is properly connected.


Any help would be greatly appreciated.

0 Kudos
Message 3 of 4

This seems to fix the error:


LIBS += -frameworks nidaqmxbase \

     -frameworks nidaqmxbaselv

0 Kudos
Message 4 of 4