Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

USB DAQ connected to Windows 10 computer controller with C code writted in CodeBlock

I've successfully connected a hand full of National Instruments DAQs (Testing with USB-6001) to my windows 10 computer and have all sorts of control using MatLab. I'm trying to get set up using basic C program (I've found examples online, in the "NI-DAQ\Examples\DAQmx ANSI C" file and using OpenChatAI)  but most of my issues are linking libraries. I've never really been good at the library linking stuff because I do it so infrequently.

Is writing C code in CodeBlocks on a windows 10 computer for National Instruments DAQs equipment even possible?

 

I've tried all sorts of linking libraries and keep getting errors.

 

Thanks for any help

0 Kudos
Message 1 of 3
(1,129 Views)

It should be possible but I have never really worked with CodeBlocks. Most likely your problems are related to the fact that CodeBlocks by default uses the Gnu gcc as C Compiler backend. Gcc has some functionality to be kind of compatible with the Microsoft compiler (MSVC) but it’s anything but seamless. You can get it to work with enough command line magic but it is generally much easier if you use the MingW backend, which is gcc but optimized to work together with MSVC compiled binaries. And Windows link libraries that come with NI drivers are all generated with MSVC. Trying to use them with the standard gcc is asking for big trouble if you are not a gcc magician. 😀

 

The easiest by far would be to use Visual Studio (Code) or at least the MSVC compiler as CodeBlocks compiler backend.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 3
(979 Views)

I got it to work from CodeBlocks

 

First the code needs to include the NIDAQmx.h header e.g.:

#include <C:\Program Files (x86)\National Instruments\NI-DAQ\DAQmx ANSI C Dev\include\NIDAQmx.h>

 

Then the compiler link stuff needs to be set up

 

click Settings on to top, then Compiler... then linker setting. add the following to the "Other linker options"

 

-L "C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\lib64\msvc"
-lNIDAQmx

 

May need to change the address to match where the files are. I forget exactly what I did to get the file as I downloaded all sorts of drivers trying to get this to work.

0 Kudos
Message 3 of 3
(935 Views)