03-21-2005 02:51 PM
05-04-2005 01:20 AM
05-04-2005 08:56 AM
@Jason Newton wrote:
is it really so hard to add support for another compiler?
05-04-2005 01:08 PM
05-05-2005 09:41 AM
05-05-2005 11:51 PM
05-06-2005 08:04 AM
@stadel wrote:
1) Jason's method seems to work fine, but I'm concerned, that this method might mess up the stack. As I understood __cdecl means, that the calling function removes the parameters from the stack after the function returned, while __stdcall means, that the function removes the parameters itself. gcs already pointed out that this calling convention is important.
2) gcs' suggestion of using attribute does not work (at least I wasn't able to find a difference, when using __attribute__((stdcall)) instead of __stdcall), but I had no experience with these compiler details so far.
3) a new approach to the problem: gcs also stated that "the NIDAQmx.lib library does have the symbols that are needed". This is surely true, but there seem to be different naming (or "decoration") conventions, as described at
Stdcall and DLL tools of MSVC and MinGW
In short: the internal represantations of function names have different "decorations". Especially gcc expects, that "@nn" (where nn is the size of all parameters in bytes) is appended to stdcall function names, while the MSVC dll uses the plain name without the "@nn".
Using Microsoft DLL's when Compiling Cygwin or Mingw describes a workaround. Basically one has to write a .def file and then create a library with the "right" names:
dumpbin /exports nidaqmx.lib
, the symbols are prefixed by an underscore and appended with the size of their parameters (e.g., _DAQmxWriteRaw@32). In fact, the NIDAQmx.lib is the import library for the nicaiu DLL. So, you shouldn't need to create your libmynicaiu import library. NIDAQmx.lib is just such a library.
1) call gcc to find the missing function names:
$ gcc Acq-IntClk.c -o Acq-IntClk.exe NIDAQmx.lib
gcc complains about undefined references as before.
05-07-2005 05:48 AM
# ifndef __stdcall
# define __stdcall __attribute__((stdcall))
# endif
$ gcc Acq-IntClk.c -o Acq-IntClk.exe NIDAQmx.lib
Temp/ccQBbaaa.o(.text+0xc7):Acq-IntClk.c: undefined reference to `DAQmxCreateTask@8'
Temp/ccQBbaaa.o(.text+0x104):Acq-IntClk.c: undefined reference to `DAQmxCreateAIVoltageChan@40'
Temp/ccQBbaaa.o(.text+0x13a):Acq-IntClk.c: undefined reference to `DAQmxCfgSampClkTiming@32'
Temp/ccQBbaaa.o(.text+0x150):Acq-IntClk.c: undefined reference to `DAQmxStartTask@4'
Temp/ccQBbaaa.o(.text+0x189):Acq-IntClk.c: undefined reference to `DAQmxReadAnalogF64@36'
Temp/ccQBbaaa.o(.text+0x1c4):Acq-IntClk.c: undefined reference to `DAQmxGetExtendedErrorInfo@8'
Temp/ccQBbaaa.o(.text+0x1d8):Acq-IntClk.c: undefined reference to `DAQmxStopTask@4'
Temp/ccQBbaaa.o(.text+0x1e6):Acq-IntClk.c: undefined reference to `DAQmxClearTask@4'
dumpbin /exports nidaqmx.lib
contains "_DAQmxCreateTask@8", as you already pointed out. To my surprise, the output of dumpbin /exports libmynicaiu.a
also contains "_DAQmxCreateTask@8"! (libmynicaiu.a is build with dlltool as desribed in my last mail.)dumpbin /exports nicaiu.dll
reveals only "DAQmxCreateTask" (without any decoration!). It seems, that my home-made "libmynicaiu.a" contains additional information that allows gcc (and the linker called by gcc) to locate the functions inside nicaiu.dll. But this is just a guess!dumpbin /exports nidaqmx.lib
. This helps a lot.05-08-2005 10:14 AM - edited 05-08-2005 10:14 AM
Message Edited by JoeSavage on 05-08-2005 10:18 AM
05-08-2005 04:06 PM - edited 05-08-2005 04:06 PM
Message Edited by Jason Newton on 05-08-2005 04:14 PM