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: 

import .so into myRio Labview

Helo, 

 

I create example library file  "math.so" for myRio LinuxRT.

 

source code :

 

int math(int a, int b)

{  return a+b;  }

 

Please, How can I import this file to myRio and use it in Labview code for adding two numbers?

My "Call library function" can import only "math.dll" file not "math.so" library.

 

Thank you for all your assistance

 

0 Kudos
Message 1 of 10
(3,596 Views)

Hello,

In order to call external code from / within LabVIEW on the NI Linux Real-Time operating system, the code must be compiled into a shared object file, or .so file.

This is the general equivalent to a .dll in the Windows environment.  National Instruments provides C & C++ Development Tools for NI Linux Real-Time, Eclipse Edition which includes the Eclipse IDE and GNU C cross-compilers for Linux. This setup can be used to perform the compilation.

 

Here a tutorial for more information on this topic:

http://www.ni.com/tutorial/14690/en/

 

This other link is about how to import Shared Library Wizard in LabVIEW.

 

If this solves your problem, please mark it as solved, so that other users with similar problems can find the solution easier.

 

Thanks and Regards,

James

Greetings and Regards,
James
0 Kudos
Message 2 of 10
(3,568 Views)

@FaustDantes wrote:

Helo, 

 

I create example library file  "math.so" for myRio LinuxRT.

 

source code :

 

int math(int a, int b)

{  return a+b;  }

 

Please, How can I import this file to myRio and use it in Labview code for adding two numbers?

My "Call library function" can import only "math.dll" file not "math.so" library.

 


You need to make sure that the VI is actually located inside the myRIO target of your project file. The location of a VI determines what target settings are used such as preferred path format, but also what compiler backend will be used to create the executable code (since the myRIO uses an ARM CPU instead of the x86 CPU on your Windows system, the code needs to be compiled into a very different form).

If the VI is located inside the myRIO target and opened from there, you should have no problems in selecting a .so file instead of a .dll file. Of course you need to compile the .so file with a compiler that is configured for the ARM code generation too. This is easiest to do by using the NI provided Eclipse toolchain an configuring as detailed in their document. A .so created with a normal Linux system on your PC will not work as that would be a compiled library for the x86 CPU and interface to the standard Linux libraries, which likely won't be entirely compatible to the Linux libraries on the myRIO too, since the myRIO uses a significantly older Linux kernel than most current Linux distributions for the desktop.

Rolf Kalbermatter
My Blog
Message 3 of 10
(3,563 Views)

Helo James,

 

Sorry for my bed english.

 

I have "MyLibFile.so"  library which was created form Eclipse, as you recomend.

then I add that file to directory  /usr/local/lib   on myRio ...

but when I create new  VI project on myRio as is on tutorial  http://www.ni.com/tutorial/14690/en/

step 2  point 8 .. I added Connectivity»Libraries & Executables

 

I put     /usr/local/lib/MyLibFile.so    into Library name or path  

but my Labview can not load that library as on Figure7. 

I am sending that setting in attachment.  

Do you have any idea what I am doing wrong? 

 

Thank you for any help you can provide.

 

Best Regards 

Michal

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

It's always hilarious when people have such problems and feel, attaching a single image explains everything about their problem.

 

Attach the VI you created, the shared library and the source code for it. Then we might be able to look at it and see what you actually did!

 

A Linux command line 

readelf -a -W <elffile>

can provide a lot of information such as if it is even a valid shared library and for which platform it was compiled.

 

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 10
(3,500 Views)

Helo, 

 

It is unnecessary because I attached only Connectivity»Libraries & Executables

component into VI and double click on it.

After that i write path into as I show on image.

 

But If it helps you I am sending VI and linux library "libmmmathLib.so" 

and  source code : 

#include "testmath.h"

#include <stdio.h>

 

int testadd(int a, int b)
{  return a+b;  }

 

and header file :

#ifndef TESTMATH_H_
#define TESTMATH_H_

int testadd(int a, int b);

#endif /* TESTMATH_H_ */

 

Best regards 

Michal

 

Download All
0 Kudos
Message 6 of 10
(3,491 Views)

Well you see, having something more to look at than a pic is usually always helpful. That is definitely true for things like the Call Library Node setup dialog which has several tabs and a pic only shows one of them and even if you make a screen shot of each, there are configuration options that are not easily visible in a pic.

 

But in your case the problem is the shared library. Using the readelf command line tool, one can see various things. You did create a 32 bit ARM library, so that is ok. But your function testadd() is not present at all in the shared library. Somehow your testmath.c file did maybe get compiled but not really properly linked into the shared library.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 10
(3,475 Views)

Thank you for prompt answer,

 

Could you please or anyone send my some easy "Hello World" .so  library sourcce code? 

I will be very pleased.

 

Thank you all for any help and response.

 

Best regards

Michal

0 Kudos
Message 8 of 10
(3,472 Views)

The problem is not the source code. Your sample should compile fine and create a valid function. The problem must be somewhere in the project settings.

 

C compilers and linkers have a few hundred to thousand command line options that change a myriad of things how code is created. Some are more cosmetic but many are very important. The GNU C toolchain is extra complicated since there are in fact a few dozen different platforms (CPUs and OSes) for which it can be compiled and many options are in fact platform specific.

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 10
(3,470 Views)

Would you be so kind and send me some "easy" .VI where is .so library called?

whih I can test  on NI myRio1900.

 

Thank you for any help.

Michal

 

0 Kudos
Message 10 of 10
(3,432 Views)