From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot deploy a shared library (so file) to a Linux RT target

Solved!
Go to solution

Dear all,

 

I have trouble when deploying a LabVIEW program to a Linux RT target (sbRIO 9627). In the program, I created a 32-bit shared object file and used Call Library Function Node to call the so file. I am using LabVIEW 2017. The so file was created from a 32-bit Ubuntu by gcc that I compiled a c file. To debug the issue, I wrote a very simple c code named sum2.c:

       int sum2(int x, int y)

        { 

          int result;

         result=x+y;

         return result;

        }

Then I compiled:

gcc -c -fpic sum2.c
gcc -shared -o libsum2.so sum2.o

  Then, libsum2.so was generated and I used Call Library Function Node to call the function sum2. However, when I ran the LabVIEW program, it said:

LabVIEW: Failed to load shared library libsum2.*:sum2:C. Ensure that the library is present on the RT target. Use either MAX to install NI software or FTP to transfer custom libraries to the RT target. 
Deployment completed with errors.

 

I read some threads to handle the issue: 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019N4SSAU&l=en-US

But it still does not work.

Can anyone help me out?

 

Thank you very much.

-Phuong

 

0 Kudos
Message 1 of 4
(2,484 Views)

Have you been able to locate the .so file on the RT target? I would copy it in the /home/lvuser folder and set the Call Library Function Node to load the .so file by path.

Lucian
CLA
0 Kudos
Message 2 of 4
(2,422 Views)
Solution
Accepted by topic author PH90

The sbRIO-9627 uses a Zync7020 FPGA with an integrated ARM CPU. Your Ubuntu so file was created on an Intel x86 stystem with a GCC compiler creating compiled object code for a x86 CPU architecture. If it is the 32-bit version of the GCC toolchain we can't even check from the information you show. You would need to use a VERY old Ubuntu version that it would be still the 32-bit version of Ubuntu. Otherwise the kernel is a 64-bit version and the installed GCC compiler is a 32-bit/64-bit variant and usually defaulting to 64-bit compilation without the extra -m32 switch.

 

But independent if your *.so file is really a 32-bit object format as you claim or a 64-bit object format, it was compiled for the Intel x86 CPU architecture and can't run on the ARM system.

 

You need to compile your C source code with a compiler that creates the correct object format. The most easy solution is to install the develop tools on your NI sb-RIO system through the use of opkg. Then you can basically issue your commands again through a terminal session on the controller and this will result in a properly compiled shared library. Or you can download the cross compiling toolchain that NI provides and compile the correct format on your Windows system, but that is a bit more tedious as you need to configure several things correctly in the Eclipse based toolchain, depending on the target you want the shared library to run.

 

NI Linux comes in two flavors. One runs on the ARM CPU contained in the Zync7020 FPGA chip, the other runs on an x64 compatible CPU, the 64-bit mode of any Intel/AMD x86 compatilble CPU. Why these two you may ask. Well an Intel compatible CPU is quite a bit more expensive than the entire XC7020 FPGA chip and also requires more and more expensive peripheral chips. As compensation it also outperforms the XC7020 ARM CPU easily, as it runs at significantly higher clock speeds.

 

Take a look here.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 4
(2,398 Views)

Thank you very much for your reply. It works now. Use cross-compile for arm and copy the so file to /home/lvuser.

0 Kudos
Message 4 of 4
(2,381 Views)