LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call Library Function Node and RT target PCI 7030

First of all I would like to thank to Darin for his fast answer. The application I have sent presents nearly the simplest of DLL that can be built up and despite of that the download process on the PCI 7030 target failed (Failed to load shared library EasyDLL.dll on RT target device.). I attached the source code of this DLL. Please let me know where is potential calling of another DLL or WinAPI that is not supported by the RTOS. Or it is necessary to set some special options for compiling and linking when creating the DLL library for PCI 7030 target?
Download All
0 Kudos
Message 1 of 2
(2,982 Views)
OK There are several points to make (that I have learned though this whole process). First of all, building the DLL's for RT are most easily done with using LabWindows/CVI. CVI provides a special option for Run-Time support in the Build Target Settings. With other compilers, the whole build process seems to be very fragile. That recommendation aside, I did manage to get your example to work using VC++ 6.0 (and I am told that it should work for 5.0 as well). On the other hand Visual Studio .Net will NOT work for creating RT DLL's. (this bug is fixed in future LVRT releases)

In VC 6, I created a New project first. I selected Win32 Dynamic Link Library as the project option. The next window asks if you want an empty project or simple DLL project. I selec
ted simple DLL project, and then replaced its generated .cpp file with your DLL source code file. Then I built it, and loaded it with your VI in LabVIEW and it worked fine. As far as changing project options, the preferred Run-Time Execution style is Single Threaded, but it works for any of the other multi-threaded options as well.

I say that its fragile, because I'm still not sure what VC settings caused it to fail several times when I tried creating the project from scratch. But when you go thru the VC steps listed above it worked like a dream. One possible reason for the trouble is that RT DLL's may be extra-sensitive to the passing of pointers; since pointers are not a native data type in LabVIEW.

Another little-known tip for DLL writing, try not to use malloc calls in your DLL's. You can, but it makes things more complicated. You will be much better off declaring your variables in labview and passing them through the left side of the LabVIEW Library Node.

Also,
there's tons of information on DLL writing tips in general located in the LabVIEW help system by searching for the document "Using External Code in LabVIEW".
Darin Gillis
NI - Chief Product Owner - VeriStand
Message 2 of 2
(2,982 Views)