LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running dll file on RT target

Highlighted

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

0 Kudos
Message 1 of 42
(3,198 Views)
Highlighted

I forgot to attach the file. Here is!

0 Kudos
Message 2 of 42
(3,195 Views)
Highlighted

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.

0 Kudos
Message 3 of 42
(3,158 Views)
Highlighted

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

0 Kudos
Message 4 of 42
(3,133 Views)
Highlighted

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

 

 

Ross S.
Applications Engineering
National Instruments
0 Kudos
Message 5 of 42
(3,064 Views)
Highlighted

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.

 

 

0 Kudos
Message 6 of 42
(3,027 Views)
Highlighted

@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.

Rolf Kalbermatter
Averna BV
Message 7 of 42
(3,004 Views)
Highlighted

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:

 

HMI-RT.JPG

    • Generating the DLL file.
    • Creating HMI and RT Vis under a project.
    • Addressing DLL file in Call Library Function Node inside RT VI as: I:\NI Forum\Vis\ali.dll (where I: is a drive in Host computer)
    • Building executable: The DLL file is not added as always included.
    • Receiving: “Failed to load DLL…”.

    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.

    • Where I should copy the DLL file on target? (Which folder exactly?)
    • How should I address DLL on Call Library Function Node? Is it sufficient to simply address the DLL file on the host?

    Thanks again.

    Regard

0 Kudos
Message 8 of 42
(2,973 Views)
Highlighted

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)

0 Kudos
Message 9 of 42
(2,959 Views)
Highlighted

Hi,

I have tried the first solution, first I copied the DLL to the c:\ni-rt\ali.dll

 

Solution2-2.JPG

 

then I adressed the DLL on Call Library Function Node as:

 Solution1-1.JPG

 

But I got the following error:

 

Solution1-2.JPG

 

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.

 

Solution2-1.JPG

 

What should I do?

0 Kudos
Message 10 of 42
(2,948 Views)