Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Error: NIDAQmx.lib: error adding symbols: File in wrong format collect2.exe: error: ld returned 1 exit status

Solved!
Go to solution

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 ?

 

0 Kudos
Message 1 of 4
(4,649 Views)

Adding the associated file.

0 Kudos
Message 2 of 4
(4,648 Views)
Solution
Accepted by topic author Subha007

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!

 

 

Claire M.
Technical Support
National Instruments
Certified LabVIEW Developer
0 Kudos
Message 3 of 4
(4,615 Views)

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.

 

 

0 Kudos
Message 4 of 4
(4,608 Views)