I'm using Qt creator 3.5.1 to try and compile c code from a National Instruments DAQmx example.
To do this I need to include a header file "NIDAQmx.h" and link a library file "NIDAQmx.lib". Both this files are present in the project folder.
When I try to compile with msvc 2013 I get the error:
LNK1181: cannot open input file 'NIDAQmx.lib'
Searching the internet I find this is a common issue and the error code 'LNK1181' means the compiler can't find the library. But all cases presented are very specific and I couldn't find a clue to why this is not working.
Here is my .pro file:
QT += core
QT -= gui
TARGET = Test4NI
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += \
main.cpp
win32: LIBS += -L$$PWD/./ -lNIDAQmx
INCLUDEPATH += $$PWD/.
DEPENDPATH += $$PWD/.
So, the last 3 commands were added by QtCreator itself when I added the library with the wizard by right clicking the project name and selecting 'Add Library...'. I have also tried to add the path with both 'INCLUDEPATH += "$absolute path" ' and with 'LIB += "$absolute path\NIDAQmx.lib" ', but to no avail.
And below is the example code in the main.c++ file. I took the code from the orignal c example and pasted it on 'main.c++'. I don't believe this to be the source of the issue, as it is an error about library include.
#include <stdio.h>
#include "C:\BK\This\WorkEn\Qt\Test4\Test4NI\NIDAQmx.h"
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(void)
{
int32 error=0;
TaskHandle taskHandle=0;
int32 read;
float64 data[1000];
char errBuff[2048]={'\0'};
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
/*********************************************/
// DAQmx Read Code
/*********************************************/
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByChannel,data,1000,&read,NULL));
printf("Acquired %d points\n",(int)read);
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
So you can see I include the header file with an absolute reference as it wasn't working any other way.
It seems like something silly. I've been at this for the last days.
I hope it's solved soon.
Thank you