12-27-2023 10:23 AM
You are trying to link with the 64-bit link library. Are you sure your project is configured as 64-bit compilation?
12-27-2023 05:36 PM
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
12-27-2023 07:30 PM
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.
12-27-2023 07:53 PM
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
12-28-2023 04:57 PM
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
12-28-2023 05:40 PM
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!
12-30-2023 10:38 AM
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.
12-30-2023 12:47 PM
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.
12-30-2023 02:32 PM
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.
12-30-2023 03:35 PM - edited 12-30-2023 03:41 PM
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).