LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Library Issue with Real Time Module

Hi everybody,

 

A friend and I are trying to develop a custom library of thermodynamic properties that can be used in labview. The library has been made by him and is already working. He created a dll file and we are trying to use it with labview. The dll (named CoolProp.dll) is working well (it's called in a VI named CoolProp.vi) except when I want to use it on my cRIO. I have the following error 

 

Deploying CoolProp.viCoolProp.vi loaded with errors on the target and was closed.
LabVIEW: Failed to load shared library CoolProp.dll: Props:C. Ensure that the library is present on the RT target. Use MAX to install NI software or FTP to transfer custom libraries to the RT target.
LabVIEW: Failed to load shared library CoolProp.dll:get_errstring_copy:C. Ensure that the library is present on the RT target. Use MAX to install NI software or FTP to transfer custom libraries to the RT target.

 

Can someone help me on this ? I try to use MAX to find the folder where my VIs are deployed without succes. I assume I have to upload on the cRIO the dll file but I am not sure of that neither where to upload it.

 

Thank you for your help.

 

Arnaud

Message 1 of 10
(4,892 Views)

Hey Arnaud,

 

The issue here has to do with trying to use the dll without compiling it for the proper OS. My guess is that you're using a cRIO 907x or similar that is running the VxWorks RTOS. If this is the case, then you have to specially compile your dll into a .out file so that it can be called from the OS. This process is described here:

 

Developing Shared Libraries for the cRIO-901x and Other VxWorks Targets

http://www.ni.com/white-paper/5694/en

 

However, just in case you're using a cRIO 900x or 908x, check this KnowledgeBase article to find out which RTOS your target is running.

 

What Operating System is my Real-Time Controller Running and Why?

http://digital.ni.com/public.nsf/allkb/35F1FD98520D6E0E8625783A005AF557

 

If you're running Pharlap then using a regular dll should work and its probably just missing from the target. In that case try building it into an RT Executable and moving the dll into the Always Included section of the build specification.

 

--Ryan S.

0 Kudos
Message 2 of 10
(4,861 Views)

Hi Ryan,

 

thank you very much for answering me. I have a cRIO 9022 and I have just checked, the OS is VxWorks. I'll try to follow the process you gave me and I'll have you know if it's working. However this seems to be the solution to the problem we have.

 

Arnaud.

0 Kudos
Message 3 of 10
(4,843 Views)

Ok, So I am Arnaud's friend who is trying to compile for VxWorks.  What a pain...  I have a fairly large open-source library CoolProp coded in C++ that is used to obtain fluid thermodynamic and transport properties in the same sort of way that REFPROP works.  I already have a wrapper for "normal" labview working by calling my DLL. I have compiled in MSVC and g++ without any major problems, and written wrappers for almost 10 different programming environments.

 

I have a whole lot of C++ files (~50), and I have followed the directions on building the shared library ( I had to get a virtualbox image of WinXP32 bit to get the compiler to work - also not fun).  Apart from some odd errors ("EOS" seems to be a reserved word/macro on PPC, and the clock doesn't seem to work), I have something that compiles.  But even when I load it into the ni-rt/system folder on the cRIO, I get errors on the library import.

 

So I thought that I would compare the exports of my library with the example file, which runs fine.  If I run "nmppc example.out" on the file generated, I get

 

00000008 D _ctors
00000000 D _dtors
0000011c T _GLOBAL__D_gExample
000000e4 T _GLOBAL__I_gExample
00000000 D _VX_START_DATA
00000000 T _VX_START_TEXT
00000050 t _Z41__static_initialization_and_destruction_0ii
00000000 T exampleFunction
0000003c T exampleSetFunction
00000000 B gExample
         U printf

which looks fine - we see the two functions we want, but pretty much nothing else.

 

On the other hand, when I run "nmppc CoolProp.out" on my library, I get a larger amount of output (as attached).  I use STL containers quite a bit, so I think some of the exports are related to that.  But I do see the main functions Props, Props1, and a stupid function F2K (Fahrenheit to Kelvin conversion) with the prototype

 

double F2K(double TF)

 

which I have often used to do debugging of calling conventions.

 

Even when I build a stripped down VI that just calls the F2K function, it won't load.  I have applied the extern "C" to the functions that I want exported, but it doesn't seem possible to keep all the other functions from also being exported.  Thus the .out file is actually a static library, not a dynamically loaded library, right? 

 

I am a bit flummoxed and could use any help the community can provide.

 

Thanks,

Ian

0 Kudos
Message 4 of 10
(4,816 Views)

Hello Belli,

 

I have found a smaller document that should show you the most common reasons for these types of issues.

I don't know up to (or better said down to) which detail you have read the document provided by Ryan S.

 

Here are some examples of what could have gone wrong:

http://digital.ni.com/public.nsf/allkb/5A267EF5471758CA86257233006EF3D8?OpenDocument

 

The original error is because it will not auto-download/auto-deploy.

In which directory on the RT target did you place your .out file in?

 

 

 

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
Message 5 of 10
(4,791 Views)

Hi Thierry,

 

Thanks, I ultimately, after a lot of fighting, I did get everything to compile properly.  A couple of comments:

 

Some things just don't work in the PPC gcc build that work in conventional gcc builds.  The CLOCKS_PER_SEC macro in the time.h header points to a function that doesn't work.  The <complex> header file seems to be broken.  All the files that use complex won't link properly and they complain about missing symbols _Nan, _Inf, _Dtest, and _Exp.  Not clear what the problem is there.

 

The .out file is then put into the ni-rt/system folder on the cRIO and things work ok.

 

Ian

0 Kudos
Message 6 of 10
(4,777 Views)

If you want to to, then we could do some extra debugging on the code to see what is going wrong (I'm always curious about this).


However, if you don't have time left to do this further troubleshooting, then I also understand of course

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 7 of 10
(4,771 Views)

I might mess around with this a bit if I get a bit of free time, but at the moment, what I need to work, works, so I am not too interested in further explorations.

 

Ian

0 Kudos
Message 8 of 10
(4,757 Views)

Ok!

 

Then just let us know when you find the time.

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 9 of 10
(4,753 Views)

Ok, I am now revisiting this thread.  I have recompiled our library, and the one issue that I cannot resolve (or workaround) is that the functions _Inf, _Nan, and _Dtest do not appear to be included in the cRIO standard library.  These functions are needed by the

 

#include <complex>

 

include.  Are they in another library that we need to link into our library?  The makefile can be seen at https://github.com/ibell/coolprop/blob/master/wrappers/Labview/vxWorks/Makefile

 

When I try to run a VI that calls our library, I get errors about the _Inf, _Nan, and _Dtest symbols being missing.

0 Kudos
Message 10 of 10
(4,588 Views)