12-10-2018 11:11 AM
I am currently working on 64 bit m/c creating a CGO project in Visual Studio code which accesses NIDAQmx.lib. I am using the associated .lib and .h files as follows in the .go file.
/*
#cgo LDFLAGS: -L${SRCDIR}/libs -lNIDAQmx
#include "NIDAQmx.h"
#cgo amd64 386 CFLAGS: -DX86=1
*/
How when I build I am getting the error :"Error: ......../NIDAQmx.lib: error adding symbols: File in wrong format collect2.exe: error: ld returned 1 exit status.
The version of gcc used by Visual Studio Code is :gcc version 5.1.0 (tdm64-1).
Any suggestions ?
Solved! Go to Solution.
12-10-2018 11:13 AM
Adding the associated file.
12-11-2018 03:55 PM
I'll start this with the caveat that I'm not familiar with CGo. I can say that this isn't a DAQmx specific error, and it seems to come up when the binary you're trying to use isn't compiled correctly for the compiler you're using.
Which directory does the DAQmx.lib file you're using come from? If you're using a gcc compiler, but using the binary in the msvc directory, i could see that throwing some fits, though I haven't tried it myself. Additionally, bitness seems to throw this error--using 32 versus 64 bit.
Just some thoughts!
12-12-2018 02:28 PM
Yes, that's exactly the problem. Not sure if there is a 64bit compatible version of NIDAQmx.lib compatible with gcc.
CGO uses GCC.I tried to compile the just as a c code using :
NIDAQmx.h - C:\Program Files (x86)\National Instruments\NI-DAQ\DAQmx ANSI C Dev\include
NIDAQmx.lib- C:\Program Files (x86)\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc
but got
undefined reference to `DAQmxCreateTask'
undefined reference to `DAQmxCreateDIChan'
undefined reference to `DAQmxStartTask'.....
I swapped it with a 64bit version from C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\lib64\msvc and got the following:
./NIDAQmx.lib: error adding symbols: File format not recognized ( collect2.exe: error: ld returned 1 exit status
Got this code compiling with gcc using the generated library libmynidaq.lib
dlltool --input-def samplenicaiu.def --dllname nicaiu.dll --output-lib libmynidaq.lib -k.
Thank you.