07-15-2009 05:16 PM
I am writing a dll to be loaded into a regular tcl shell. This dll is supposed to add commands to the shell that will handle a PCI-6221 card. So, my tcl script will load the dll, which will call C functions from the NI-DAQmx interface. I wrote the dll, which compiles OK. The DLL is loaded into the TCL shell with the load command. When the DLL is loaded, it loads the nicaiu.dll and others which this one request.
When the first tcl command that calls DAQmxCreateTask is called, the tcl ends due to an invalid memory access. I followed the program and it seems to be calling the dll function DAQmxCreateTask, which generates the invalid memory access.
I am wondering where the problem would be. I imagined a few possibilities, like the NI DLL not being initialized properly, some problem with threads, or eventually problems with C++ (the language I used to write my DLL).
Does anyone know about some sort of initialization I am supposed to do explicitly? Does anyone used nicaiu.dll from inside a tcl script? As an additional information, the compiler I am using is MinGW 5.1.4.
07-16-2009 12:46 PM
Hey Sentieri,
Aha..The attahced dcoument might thorw some light on the issue. Got it from a colleague who got it from NI.
Goodl luck
-Lab
07-16-2009 01:00 PM
Thanks for the information. The file you sent me has instructions about compiling code with MinGW. I had already solved that problem. I was able to compile and link without errors. But when my C++ code called the function DAQmxCreateTask, then this function accessed an invalid memory position (I traced the code and the access was inside NI dlls). I have just rewrote the code in C (instead of C++) and now my dll is working correctly, so I presume the problem is some control area of the C++ code that was not being initialized.
So I will use C instead of C++. My problem is that I will not be able to use code I have in C++.
Thanks,
07-16-2009 02:51 PM
Hey,
I see ! Thanks for the update.
-Lab.