Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Howto use NIDAQmx with mingw gcc 3.4.2

To use NIDAQmx with mingw/gcc, there must be set up a library for linking your application against.
Delivered is a library NIDAQmx.lib and a header NIDAQmx.h for use with Microsoft Visual C++.
It is not possible to link your application against this lib like you would do with
   gcc Acq-IntClk.c -o Acq-IntClk.exe NIDAQmx.lib.
You will get a lot of Errors.
So within this Forum i found a lot of tips how to do it. I've combined all tips and got my solution for this problem.
I've attached the new NIDAQmx.h, libmynicaiu.a and a distribution package for devcpp NIDAqmx74-1.0-1spec.DevPak.
I hope my solution is useful and will help you a little.


0 Kudos
Message 1 of 11
(13,057 Views)
Well, here is possibly more universal result of my forum compilation.

This bash script creates import library for mingw from NIDAQmx.lib:
-----------------------------------------------------------------
#!/bin/sh
PATH="$PATH:/c/Program Files/Microsoft Visual Studio/Common/MSDev98/Bin:/c/Program Files/Microsoft Visual Studio/VC98/Bin/"
dumpbin /exports "c:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc\NIDAQmx.lib" > nidaq.exports
echo LIBRARY nicaiu.dll > nidaq.defs
echo EXPORTS >> nidaq.defs
sed "1,/ordinal *name/d;/^$/d;/Summary$/,+100d;s/^ \+\([^ ]\+\)\( .*\|\)$/\\1/;s/^_\(.*\)$/\1/" nidaq.exports |sort >> nidaq.defs
dlltool  -k -d nidaq.defs -l libnidaq.a c:/WINDOWS/system32/nicaiu.dll
-------------------------------------------------------------------

As a result libnidaq.a is created.

Here is how to use this library and _unmodified_ NIDAQmx.h to build one of ni examples:

gcc -D__int64="long long" -I../../../../../DAQmx\ ANSI\ C\ Dev/include/  ContGen-IntClk-AnlgStart.c -o ContGen-IntClk-AnlgStart.exe -Ld:/Prog/NI -lnidaq

Regards.
Vladimir

Message 2 of 11
(13,033 Views)
Here are the files created with Vladimir's script, using NIDAQ version 8.3 for everyone's convenience.
I created them using Cygwin and Microsoft Visual C++ 2005 Express Edition, tested using Qt 4.1.4 and the Qt included MinGW.
 
 
Message 3 of 11
(12,928 Views)
In n.zip there are the files:

libnidaq.a
nidaq.defs
nidaq.exports
NIDAmx.lib
README.txt
NIDAQmx.h

In the README.txt it states:

When compiling in Windows,   Link with flag: -lnidaq
When compiling in Linux,         Link with flag: -lnidaqmx

Put these files in your library path before compiling and linking.

The library file (NIDAQmx.lib) is from Windows NIDAQ version 8.3

Where would I put the NIDAmx.lib file so the when I compile on a Cygwin system, the -lnidaqmx will work.

I assume that the libnidaq.a is for compiling on Windows.

Anyhow, if somebody would provide for Cygwin the following:

1.  main.c - which prints out the fact that the compiled code is functioning.
2.  command line which makes the main.c and links in the nidaqmx.lib
3.  location on a Cygwin system where the nidaqmx.lib file resides.
4.  A description of all the files included in the .zip file.

thaks


0 Kudos
Message 4 of 11
(11,671 Views)

Qt 4.7 with included mingw can use NIDAQmx.lib "as is" with LIBS += "<full path>\NIDAQmx.lib" statement in pro file.

0 Kudos
Message 5 of 11
(9,949 Views)

That is wonderfull!

0 Kudos
Message 6 of 11
(9,629 Views)

Agreed. One thing to watch out for when using mingw with NI-DAQmx: GCC doesn't support Microsoft's __int64 type natively. Make sure to include a C library header (like stdio.h) so that __int64 gets defined before you include NIDAQmx.h.

 

Brad

---
Brad Keryan
NI R&D
Message 7 of 11
(9,617 Views)

Brad,

I am trying to evaluate and use the LabVIEW c-code Generator with Qt Creator 2.3.1, Qt 4.7.4.  I exported a very simple VI that implements y = m * x + b.  I am adding the source to my project in accordance with (http://zone.ni.com/reference/en-XX/help/373144B-01/lvcgenhelp/cgen_include_gen_code_ext_apps/) but cannot get the code to compile.  I attached my exported code - anything you can help me out with would be great!  Ideally, I would like to get this to work in a basic command line app to show that it will compile and run.  I was doing this as an example main.cpp:

 

#include <QtCore/QCoreApplication>
#include <iostream>
#include "CCGen/evalline.h"

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

std::cout << "y = " << Evaluateline(1.11, 260, 200);

return a.exec();
}

 

Any thoughts?

-cb

0 Kudos
Message 8 of 11
(9,215 Views)

Hi cb,

 

This thread is about using NI-DAQmx with mingw, so I was going to suggest that you start a new thread in a LabVIEW-related forum, but I see you already did that: http://forums.ni.com/t5/LabVIEW-Embedded/Using-LV-C-generator-with-Qt/m-p/1923189/highlight/true

 

Also, please post the exact text of the compilation errors in the other thread. The error messages are important, and you're unlikely to get much help without posting them.

 

Brad

---
Brad Keryan
NI R&D
0 Kudos
Message 9 of 11
(9,212 Views)

Thanks Brad,

I posted to your thread as a bit of a desparation move to see if you had ever successfully used c-generated code in Qt or knew anyone who had gotten it to work.  I will post some compiler errors with the other thread.

-cb

0 Kudos
Message 10 of 11
(9,204 Views)