Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Drivers for USB 6001

You are trying to link with the 64-bit link library. Are you sure your project is configured as 64-bit compilation?

Rolf Kalbermatter
My Blog
0 Kudos
Message 11 of 21
(903 Views)

I'm trying to compile 64 bit, (the computer is 64 bit) I have tried linking to the 32 bit library and I get the error: " undefined reference to `DAQmxCreateTask'"

 

Thanks for your help

0 Kudos
Message 12 of 21
(886 Views)

Which compiler are you using? MSC in that path means Microsoft C and only the Microsoft C compilers and MingW variant of GCC tends to know how to deal with the according COFF file format.

Rolf Kalbermatter
My Blog
0 Kudos
Message 13 of 21
(876 Views)

This sounds like a problem with the way you tell your program to look for your libraries. Minraries can be found under: C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C (I think they had this wrong on their website)

 

I use VC++ and i have the following setup in properties (MY_LIB is where i saved the .dll, .lib, .h files):

 

VC++ Directories -> Include Directories -> C:\MY_LIB\NI-DAQ\include
VC++ Directories -> Library Directories -> C:\MY_LIB\NI-DAQ\lib64\msvc

Linker input -> Additional dependencies -> C:\MY_LIB\NI-DAQ\lib64\msvc\NIDAQmx.lib
Linker input -> Additional dependencies -> C:\MY_LIB\NI-DAQ\lib64\msvc\nisyscfg.lib

 

Also, for the functions, documentation can be found under C:\Users\Public\Documents\National Instruments\NI-DAQ\Documentation

 

Nate

 
0 Kudos
Message 14 of 21
(869 Views)

The compiler I'm using is gcc (it works fine on another computer):

gcc.exe -c "NIUSB6001_2XAnalogIn.c" -o "NIUSB6001_2XAnalogIn.o" && gcc.exe -o "NIUSB6001_2XAnalogIn.exe" "NIUSB6001_2XAnalogIn.o" -Wall "C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\lib64\msvc\NIDAQmx.lib"

 

The library I include in the C file is:

#include <C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\include\NIDAQmx.h>

 

Its all the same on a second computer that works fine, its just this one computer that has the issues.

 

Thanks for your continued help

0 Kudos
Message 15 of 21
(853 Views)

We are getting closer. Not all GCC are equal. There are first special Windows builds from MingW or MingW-W64 and then there are many different version from all the various GCC builds.

 

Try to issue on a command line

gcc —version

 

That will almost certainly show differences between the computer it works on and your other!

 

 

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 16 of 21
(847 Views)

Yep you are likely onto something. The working computer had version 9.2.0and the non working computer has version 5.1.0.  I've been trying to update the version but even that dosn't seem simple. I will keep trying.

0 Kudos
Message 17 of 21
(830 Views)

5.1 is mega old (released 2015) I know that stock 4.x did not support Windows specialities including Microsoft C compatibility both for C pragmas and other compiler specific features as well as library formats. You had to use MingW versions of gcc to get such features (not always seamless).

Later GCC versions also added many Micosoftismes.

Rolf Kalbermatter
My Blog
Message 18 of 21
(820 Views)

I used (https://nuwen.net/mingw.html) and now I'm using version 11.2.0

 

Now I can compile from both computer with out error, but when I run the .exe it crashes with the error "The application was unable to start correctly (0xc0000142).

 

when I run the same .exe from the good computer it works fine.

 

So I can compile the same code from two computer and both .exe work on the good computer and neither work on the "bad" compute.

 

The USB DAQ works the same from NImax.

 

 

0 Kudos
Message 19 of 21
(811 Views)

Check your MingW/GCC Runtime library settings. An EXE (and DLL) always uses some C runtime library. But this C Runtime library is version dependent and can either be linked to the binary (making it bigger) or use a dynamic Runtime Library (which has to be installed separately on every computer you want to run this binary). MingW comes with extra options that can use either the old MSVCRT DLL that is always available on every Windows system or some MingW specific runtime library that is depending on the MingW version used. Use of the old MSVCRT DLL however disables pretty much all modern C features, like anything C89 and newer features.

 

Technically adding -static-libgcc and possibly -static-libstdc++ to the compiler options should include the according runtime libraries directly into your binary. Legally you have to consult the license of your MingW installation if that is allowed for the program you want to create (and possibly distribute).

Rolf Kalbermatter
My Blog
Message 20 of 21
(799 Views)