09-25-2020 11:21 AM
Hi,
I'm currently porting existing Custom Devices that used to run on Phar Lap ETS to Linux RT. The main logic of the custom devices is written in C and there is only LabVIEW "glue-code" to integrate the C code into VeriStand.
So essentially the LabVIEW code consists of different "Call Library Function" nodes. This all works very well but there is one problem I can't solve: How can I unload a shared library from LabVIEW? I'll explain why I need to unload the shared lib.
During the development phase of the custom devices there is a cycle like this:
My theory why it crashes is this: The VeriStand Engine is a LabVIEW application that keeps running permanently. So even if you undeploy, shared libraries that were loaded during the previous deployment are still kept in memory. During the next deployment, a different version of the same library is copied to the system, while the old copy is still in memory. LabVIEW doesn't like that and crashes.
This problem could be avoided if there was a way to unload shared libraries during undeployment. According to this link
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019O6eSAE&l=en-US
it can be done by wiring an empty path to all “Call Library Function” nodes. But I have no idea how you would design the LabVIEW code to do that. All custom devices are inline, so in the “Close” case I somehow would have to call all the nodes that are called in the other cases, but this time with an empty path. Any ideas?
Thanks
Dirk
Solved! Go to Solution.
09-29-2020 07:53 AM - edited 09-29-2020 07:56 AM
I realized that only one Custom Device was affected by this problem. Other Custom Devices unloaded their shared libraries just fine, without me doing anything special in the LV code (I guess LV will also call FreeLibrary/dlclose when the VI containing the "Call Library Function" nodes is closed). After analyzing the differences between the shared libraries, I found out that the problem can be solved by using the -fno-gnu-unique option for g++, see this post for details:
https://stackoverflow.com/a/51402034/4721381