Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How Can I Use The NI-DAQmx ANSI C Function Library With GCC (on Windows)?

Thank you very much for your help!
I really appreciate, that you have installed gcc and found a solution for my problem!
Best regards,
Jens
0 Kudos
Message 11 of 43
(10,582 Views)
Joe Savage's NIDAQmx.c approach, which is basically to construct an "import library" in C, seems a bit overkill.

I used MS's dumpbin /exports on the NI import library (.lib, NOT the .dll) to generate a listing of the exported symbols, which I hand-edited into a .def file. Then I used dlltool to create an import library, libnidaqmx.dll.a.

The link step is then just:
gcc -mno-cygwin example.o -lnidaqmx -o example.exe

I've attached the .def and the .a.
Message 12 of 43
(10,551 Views)
Dear experts,
I would like to make a wrapper DLL so that I can make calls from Borlands Delphi.

Stadel wrotes:
>I also found a similar topic dealing with Borland C in the knowledge base:
>"How Can I Use The NI-DAQmx ANSI C Function Library With Borland C and Delphi?"
>http://digital.ni.com/public.nsf/websearch/B09727F89DA3A06C86256F430071D88E?OpenDocument
>where an NIDAQmx.lib file for Borland C is available.

But where is the Borland C file. I could not find it.
Moreover has anyone created such a wrapper DLL and how are the calles are made?
I also looking for examples how to write and read digital IO of the USB-6501.
I have programmed an application for the DIO24 PCMCIA card with the traditional NI-DAQ driver (and with its ActiveX Components)
and works fine. But now I would like to change to the USB-6501 DIO card but have no idea how I could make it from Delphi 7.

I would be very helpfull for any advices and information.
Please send a copy to wschrabi@gmx.at of your postings. Tks
0 Kudos
Message 13 of 43
(10,484 Views)
Hi everybody,

Let me first thank you for that thread ! I used all your valuable tips to get NIDAQmx (7.4 and 8.0) work with MinGW gcc and I summed it up in a text file.

Besides that, I wrote a bash script to automate the procedure of creating a definition file, after Pablo2565's method. You can install the free UnxUtils for Windows to use it.

Finally, I used LibDump, a free utility for those, like me, who don't have a Microsoft development product and hence dumpbin.exe.

The script and the summary are in the zip attached.


Have fun !

Message Edité par dplamp le 02-23-2006 03:57 AM

Message 14 of 43
(10,227 Views)
Hello,

Thanks for the zip file. One thing that was not mentioned was the need to add "#include <windows.h>" to the sample source code.

Thanks again.

Jeff
0 Kudos
Message 15 of 43
(10,178 Views)
Hi,

I have been wrecking my head with this or the lasty two days. I have executed all your instructions to the letter and everything has worked well. Unfortunately, when I try to execute the resulting .exe I get the following pop up message:

"This application has failed to start because WINDOWSsystem32 icaiu.dll was not found. Re-installing the application may fix this problem"

What's uncanny is that it says icaiu and not nicaiu.....christ only knows why! To think that it has taken two days to run a simple C program which is meant to be ANSI C compatible and all because NI don't feel its worth supporting the worlds most popular C compiler.....seriously!

Anyway, can anyone shed some light on this ?

Thanks in advance,

Shaun.


0 Kudos
Message 16 of 43
(10,150 Views)
Dear Shaun,

I have used the method, which has developed here, since nearly a year, but I have not yet encountered your problem. So I can only make guesses.
I use cygwin and have run cygcheck on one of my executables. The part of the output below shows the the relevant dlls, which are used:

  C:\WINDOWS\system32\nicaiu.dll
    C:\WINDOWS\system32\NIPALU.dll
      C:\WINDOWS\system32\nipalut.dll
      C:\WINDOWS\system32\NIPAL32.dll
        C:\WINDOWS\system32\SETUPAPI.dll
    C:\WINDOWS\system32\nimdbgu.dll
      C:\WINDOWS\system32\niorbu.dll
        C:\WINDOWS\system32\nirpc.dll
        C:\WINDOWS\system32\WSOCK32.dll
          C:\WINDOWS\system32\WS2_32.dll
            C:\WINDOWS\system32\WS2HELP.dll
        C:\WINDOWS\system32\MSVCR71.dll
    C:\WINDOWS\system32\nicesru.dll
      C:\WINDOWS\system32\nimstsu.dll
      C:\WINDOWS\system32\nimercu.dll
        C:\WINDOWS\system32\nidmxfu.dll
          C:\WINDOWS\system32\nimhwcfu.dll
          C:\WINDOWS\system32\nimxdfu.dll
          C:\WINDOWS\system32\nidimu.dll
          C:\WINDOWS\system32\nimru2u.dll
          C:\WINDOWS\system32\nimxpu.dll

There is no icaiu.dll at all, but the root dll is called nicaiu.dll!

My guess is that there is some problem with backslashes. You have quoted the path of the dll as WINDOWSsystem32 icaiu.dll
And all backslashes are missing. Perhaps it actually was \nicaiu.dll, and the '\n' was interpreted special?

Are you really sure, that C:\WINDOWS\system32\ is in your PATH? In my case the (cygwin) $PATH is set to something like:
> echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/WINDOWS/system32
where /cygdrive/c/WINDOWS/system32 actually points to C:\WINDOWS\system32 under cygwin.

You could copy C:\WINDOWS\system32\nicaiu.dll into the directory of your executable just to check whether the error message changes (of course, several other dlls would still be missing).

I hope this is a starting point to figure out the problem.

Best wishes
Jens
0 Kudos
Message 17 of 43
(10,140 Views)
My guess is that you are using a unix-like shell to perform this step of MSVC_to_gcc.txt:

dlltool -d nidaqmx.def -D \WINDOWS\system32\nicaiu.dll -l libnidaqmx.a -k

but failing to escape the backslashes correctly.

Try running this command under the Win32 command processor cmd.exe.

In fact if you have the line

LIBRARY nicaiu.dll

at the top of your .def, and %SystemRoot%\system32 on your %PATH%, you shouldn't need the -D argument at all.

-- Pablo2565


0 Kudos
Message 18 of 43
(10,134 Views)
Thanks Pablo,

I removed the -D argument and now everything works well.....err...nearly. I can compile and run from windows cmd but i'm havng problems linking the "libnidaqmx.a" to a simple test compile using Eclipse 3.1.2, CDT 3.0.2, MinGW and MSYS. Everything compiles well in this dev env but  I keep getting the following error at the linking stage:

Invoking: GCC C Linker
gcc -oManagedTest.exe ./src/AngularPosition-Buff-Cont.o -lD:\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\libnidaqmx.a
d:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lD:\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\libnidaqmx.a
collect2: ld returned 1 exit status

I know this is beyone the call of duty....but any ideas ?

Cheers, Shaun.

0 Kudos
Message 19 of 43
(10,112 Views)
Quick post to say everything working now.

Just for the record, using Eclipse 3.1.2, CDT 3.0.2, MinGW and MSYS.

Cheers, Shaun.
0 Kudos
Message 20 of 43
(10,101 Views)