03-08-2016 02:12 AM
Hi,
I want to call a dll file using Call Library Function Node on a labview RT target (RTOS is PharLab 13.0). This file contain a simple formula (x+y=z) and was created using MATLAB Coder. I have checked this dll with “dll Checker” provided by NI and there was no Bad function in the dll.
However, when I run the code, I get an error entitled “Failed to load shared library…” as shown in the attached file. Should I copy my dll file on the Target? Where? How should I specify the address of dll file in the Call Library Function Node? The browser of Call Library Function Node do not let me chose any dll file on the target.
I have worked with Call Library Function Node in windows several times but I cannot run it on the RT target. What is the differences between running dll files in windows and RTOS?
Regards
03-08-2016 02:15 AM
I forgot to attach the file. Here is!
03-08-2016 04:36 AM - edited 03-08-2016 04:38 AM
It's not something I've ever had to do, but:
If you're building an RT Executable, you can include the dll as part of the build specification which will deploy the DLL and should prevent this problem. I believe you can then run it interactively after that and it should work because the dll is already deployed (source: http://forums.ni.com/t5/LabVIEW/downloading-DLL-to-RT-target/td-p/2306978)
How if your call library function node configured? Did you just specify the file name? If you were to try an absolute path, it would need to somewhere on the RT target (e.g. c:\ni-rt\dlls) and then FTP your DLL to that location.
There might also be some 'search paths' where the application will look for the DLL by default.
03-08-2016 10:37 PM
Dear Sam_Sharp
I created the executable but it still didn’t work.
I transferred the dll file to “c:\ni-rt” but I could not add the dll file to the project explorer window under target. I tried the Add/File/… but it did not work. It seems that some kind of permission settings do not allow us to do that. Since it was not possible to add dll file under target, the dll file is not listed as always included in the executable.
I also tried both the absolute path and single name but neither work. It is not possible to select a dll file on the target folder in the Call Library Function Node configuration.
Regards
03-10-2016 10:17 AM
Let's verify that the DLL you are trying to use is executable in LabVIEW Real Time with that particular RTOS. I've attached a link that outlines how this might be done:
http://digital.ni.com/public.nsf/websearch/0BF52E6FAC0BF9C286256EDB00015230?OpenDocument
03-14-2016 12:09 AM
As I stated in the previous posts, I have checked the dll with dll checker.
There is no Bad function on the dll but there are some stubbed imports.
03-14-2016 05:29 AM - edited 03-14-2016 05:33 AM
@alini wrote:Dear Sam_Sharp
I created the executable but it still didn’t work.
I transferred the dll file to “c:\ni-rt” but I could not add the dll file to the project explorer window under target. I tried the Add/File/… but it did not work. It seems that some kind of permission settings do not allow us to do that. Since it was not possible to add dll file under target, the dll file is not listed as always included in the executable.
I also tried both the absolute path and single name but neither work. It is not possible to select a dll file on the target folder in the Call Library Function Node configuration.
Regards
Your project is located on the host. It can not see the DLL on your target at all.
You have to make sure that the DLL is on your host in some place LabVIEW can find it (adding it to your project should make that possible).
When you build and deploy the VI to your target, the VIs will be compiled, then transfered to the target and there executed from memory. DLL references will be resolved on the target at load time of the code just before the compiled VI code is executed.
So you need your DLL really in TWO different locations:
1) On your host so that LabVIEW can load it and compile the VI code.
2) On your target so that the generated LabVIEW code can reference it
And stub functions could be fatal too. If they are called in the DLL initialization phase (when your DLL is loaded, every DLL has to have an DLLMain function in order for Windows (and Pharlap OS to be able to load it)) and such a stub call causes the DLL load routine to fail, Windows (and Pharlap OS) will abort the DLL load too and return an error code to the application, which will cause the LabVIEW runtime to consider the DLL unloadable, either because it doesn't exist or the load of the DLL failed.
03-15-2016 04:51 AM
Dear Rolf,
Thank you for your kind reply. I would like to review the procedure since I couldn’t understand your answer completely.
I have attached the project and the required DLL file and executable files. I have followed these steps:
Could you please try these steps and help me in this matter. I would be appreciate if you could also answer the following questions in your reply.
Thanks again.
Regard
03-15-2016 05:10 AM - edited 03-15-2016 05:13 AM
This is why I asked you to post the configuration of your call library function node before - you have it configured incorrectly! You are using an absolute path to a folder that doesn't exist when you run the code on your RT target! The RT target is a separate computer - it doesn't have access to files on your PCs harddrive once the code is running...
Either (as I mentioned in my post above):
- Specify the path as a path on the RT target (e.g. c:\ni-rt\ali.dll) and then put the DLL file in that location on the RT target (e.g. via FTP). The actual folder itself doesn't matter - as long as it's something that exists on the RT target.
- Specify the DLL as just the dll name (e.g. "ali.dll") and then set it to 'always include' in your build specification (this will then transfer it for you - so you don't need to worry about paths)
03-15-2016 06:19 AM
Hi,
I have tried the first solution, first I copied the DLL to the c:\ni-rt\ali.dll
then I adressed the DLL on Call Library Function Node as:
But I got the following error:
I also tried the second solution, I adress the DLL as "ali.dll" . The following picture shows that the build process do not let to select any file (also DLL) as Always included.
What should I do?