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.

Hobbyist Toolkit

cancel
Showing results for 
Search instead for 
Did you mean: 

Anyone having success building a .so file and running in LINX?

Solved!
Go to solution

Anyone having success building a .so file and running in LINX?

 

I am having trouble at the compile steps. I will post more info today.

0 Kudos
Message 1 of 12
(4,327 Views)

LINX target installed on Raspberry Pi 4 B is: 20.0.0-4

Raspberry Pi OS (32-bit) with desktop version: August 2020 (2020-08-20)

Kervel Version: 5.4

 

I follow the following steps found here: https://www.labviewmakerhub.com/doku.php?id=learn:tutorials:libraries:linx:misc:build-on-target

 

For code, I try to make the simplest C code that I can think of.  I know I can compile and run it as an exe outside of chroot on Raspberry Pi:

 

int returnZero() {
return 0;
}

int returnOne() {
return 1;
}

int main() {
return 0;
}

 

I place this code here: root@raspberrypi:/home/pi/lv_ccode/test_func.c

 

I run this command with no error while in labview chroot: gcc -c -Wall -Werror -fpic test_func.c

 

I enter the next command: gcc -shared -o libtest_func.so test_func.o

 

And proceed to get the following information:

/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find crti.o: No such file or directory
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find crtbeginS.o: No such file or directory
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lgcc
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lc
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lgcc
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find crtendS.o: No such file or directory
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status

 

I do not understand why others have had no problems at this step, however I am having errors on a simple C program.

 

So I exit labview chroot and return to the normal file location: cd /home/pi/lv_ccode

 

And repeat the above two gcc lines of commands with no errors. So now I have libtest_func.so, which I then place into chroot /usr/lib here: cp libtest_func.so /srv/chroot/labview/usr/lib

 

And verify that it is in fact there at labview chroot /usr/lib, which it is.

 

So now I use a Call Library Function Node to call this .so file that I have now created, and place it in a LabVIEW while loop will all the correct connections.

 

labview0.jpg

And then click on "Run"

 

Initializing...
Calculating dependencies...
Checking items for conflicts. This operation could take a while...
Preparing items for download. This operation could take a while...
Deploying LMH-LINX.lvlib
Deploying LMH-LINX.lvlib:Local IO.lvlib
Deploying LMH-LINX.lvlib:Device.lvlib
Deploying LMH-LINX.lvlib:myRIO.lvlib
Deploying LMH-LINX.lvlib:Interaction Parts Kit.lvlib
Deploying LMH-LINX.lvlib:Servo.lvlib
Deploying LMH-LINX.lvlib:LTC2631.lvlib
Deploying LMH-LINX.lvlib:AD9850.lvlib
Deploying LMH-LINX.lvlib:TCN75A.lvlib
Deploying LMH-LINX.lvlib:TMP3x.lvlib
Deploying LMH-LINX.lvlib:SSD1306.lvlib
Deploying LMH-LINX.lvlib:PmodACL.lvlib
Deploying LMH-LINX.lvlib:PmodACL2.lvlib
Deploying LMH-LINX.lvlib:PmodALS.lvlib
Deploying LMH-LINX.lvlib:PmodJSTK.lvlib
Deploying LMH-LINX.lvlib:PmodGYRO.lvlib
Deploying LMH-LINX.lvlib:PmodTC1.lvlib
Deploying LMH-LINX.lvlib:PmodMIC3.lvlib
Deploying LMH-LINX.lvlib:PmodMAXSONAR.lvlib
Deploying LMH-LINX.lvlib:PmodBT2.lvlib
Deploying LMH-LINX.lvlib:PmodCMPS.lvlib
Deploying LMH-LINX.lvlib:PmodTMP3.lvlib
Deploying LMH-LINX.lvlib:PmodGPS.lvlib
Deploying LMH-LINX.lvlib:HiTechnic.lvlib
Deploying LMH-LINX.lvlib:HiTechnic.lvlib:Accelerometer.lvlib
Deploying LMH-LINX.lvlib:DS1307.lvlib
Deploying LMH-LINX.lvlib:Ultrasonic.lvlib
Deploying LMH-LINX.lvlib:MMA8452.lvlib
Deploying LMH-LINX.lvlib:MPU60X0.lvlib
Deploying LMH-LINX.lvlib:ADXL345.lvlib
Deploying LMH-LINX.lvlib:MMA8451.lvlib
Deploying LMH-LINX.lvlib:BlinkM.lvlib
Deploying LMH-LINX.lvlib:WS2812.lvlib
Deploying raspberrypi(successfully deployed target settings)
Deploying LMH-LINX.lvlib:Device.lvlib:Packet Number FGV Action.ctl (1.49 K)
Deploying LMH-LINX.lvlib:Interface.ctl (1.49 K)
Deploying LMH-LINX.lvlib:Device Data.ctl (1.65 K)
Deploying LMH-LINX.lvlib:User Platform.ctl (1.49 K)
Deploying LMH-LINX.lvlib:Device.lvlib:TCP Config.ctl (1.57 K)
Deploying whitespace.ctl (1.49 K)
Deploying Trim Whitespace.vi (3.17 K)
Deploying LMH-LINX.lvlib:Device Firmware.ctl (1.70 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Firmware Version.ctl (1.56 K)
Deploying LMH-LINX.lvlib:Clean Error Call Chain.vi (10.74 K)
Deploying LMH-LINX.lvlib:Platform.ctl (1.49 K)
Deploying LMH-LINX.lvlib:Get Platform.vi (3.36 K)
Deploying LMH-LINX.lvlib:Device.lvlib:LINX VI API Version.vi (2.94 K)
Deploying LMH-LINX.lvlib:All Firmware Data FGV States.ctl (1.49 K)
Deploying LMH-LINX.lvlib:All Firmware Data FGV.vi (5.96 K)
Deploying LMH-LINX.lvlib:Error Type.ctl (1.49 K)
Deploying VISA Configure Serial Port (Instr).vi (6.69 K)
Deploying Error Cluster From Error Code.vi (7.54 K)
Deploying LMH-LINX.lvlib:Channels.ctl (1.85 K)
Deploying LMH-LINX.lvlib:Device.lvlib:LINX Device Config.ctl (1.95 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Serial Set Baud.vi (5.18 K)
Deploying LMH-LINX.lvlib:Device ID to Name.vi (6.96 K)
Deploying LMH-LINX.lvlib:Device.lvlib:TCP Close.vi (5.05 K)
Deploying LMH-LINX.lvlib:Set Device Name.vi (5.18 K)
Deploying LMH-LINX.lvlib:Device.lvlib:TCP Read.vi (5.60 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Serial Flush.vi (4.41 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Serial Write.vi (5.22 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Wait For Bytes.vi (8.91 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Checksum.vi (6.00 K)
Deploying LMH-LINX.lvlib:Device.lvlib:TCP Flush.vi (5.82 K)
Deploying LMH-LINX.lvlib:LINX Ref.ctl (1.98 K)
Deploying LMH-LINX.lvlib:Local IO.lvlib:Load Device Channels.vi (29.18 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Serial Read.vi (5.83 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Packet Number.vi (5.37 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Packetize.vi (7.36 K)
Deploying LMH-LINX.lvlib:Generate Error.vi (18.51 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Wait For Packet.vi (16.97 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Set Device Baud Rate.vi (9.98 K)
Deploying LMH-LINX.lvlib:Local IO.lvlib:Load Device Info.vi (10.42 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Serial Open.vi (6.55 K)
Deploying LMH-LINX.lvlib:Device.lvlib:TCP Open.vi (7.48 K)
Deploying LMH-LINX.lvlib:Device.lvlib:TCP Write.vi (9.18 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Send Command.vi (15.44 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get I2C Channels.vi (8.76 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get AI Ref.vi (8.66 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get Servo Channels.vi (8.76 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get QE Channels.vi (8.76 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get Max Baud Rate.vi (7.42 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get AO Channels.vi (8.76 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Synchronize.vi (11.84 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get Firmware Version.vi (8.21 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Close Device.vi (5.90 K)
Deploying LMH-LINX.lvlib:Close.vi (8.61 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get Device Name.vi (7.93 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get UART Channels.vi (8.76 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get PWM Channels.vi (8.76 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get AI Channels.vi (8.76 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get SPI Channels.vi (8.76 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get DIO Channels.vi (8.76 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Check Firmware Version.vi (11.38 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get Device ID.vi (7.23 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Get CAN Channels.vi (8.76 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Load Device Config.vi (12.20 K)
Deploying LMH-LINX.lvlib:Device.lvlib:Initialize Device.vi (15.67 K)
Deploying LMH-LINX.lvlib:Initialize.vi (12.36 K)
Deploying LMH-LINX.lvlib:Open Local.vi (5.59 K)
Deploying soImportTest.visoImportTest.vi loaded with errors on the target and was closed.
Deployment completed with errors

 

Where did things go wrong?  Any help is appreciated.

0 Kudos
Message 2 of 12
(4,286 Views)

You have a mixup of the location where you put the code. While you run in the Raspberry Pi Desktop, the /home/pi/lv_ccode/test_func.c path is in the main Pi environment. When you want to place something into the environment that the LabVIEW chroot "virtual machine" sees, you have to place it in /srv/chroot/labview/root/ when looked at from your Raspbian host environment.

 

This will be /root/ inside your LabVIEW schroot environment. Then you can proceed to compile from inside your LabVIEW chroot environment (after entering it with the command:

sudo schroot --run-session -c lv

 

Rolf Kalbermatter
My Blog
Message 3 of 12
(4,279 Views)

Thank you rolfk for your detailed response.  

 

So instead I do the following command from  /home/pi/lv_ccode/ folder: 

 

cp test_func.c /srv/chroot/labview/root/

 

Then enter into chroot:

sudo schroot --run-session -c lv

command: cd /root

 

Then I proceed to compile from inside your LabVIEW chroot environment:

 

I run this command with no error while in labview chroot: gcc -c -Wall -Werror -fpic test_func.c

 

I enter the next command: gcc -shared -o libtest_func.so test_func.o

 

And proceed to get the following information:

 

root@raspberrypi:~# gcc -shared -o libtest_func.so test_func.o
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find crti.o: No such file or directory
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find crtbeginS.o: No such file or directory
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lgcc
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lc
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lgcc
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find crtendS.o: No such file or directory
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status

 

It appears your instructions did not  fix my problem. 😞 Would you know what else could be my solution or fix?

 

It appears the compiler cannot find some files during the compiling process.

 

0 Kudos
Message 4 of 12
(4,260 Views)

Does anyone have a compiled .so file that I can borrow that you know works?  I would like to at least troubleshoot and narrow down where the problem resides.

0 Kudos
Message 5 of 12
(4,256 Views)
Solution
Accepted by bbelley

I found this article worked perfectly as a workaround to making my .so file.  I was then able to run my same labview program successfully with no errors.

 

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

 

Thanks.

0 Kudos
Message 6 of 12
(4,211 Views)

I can confirm that using the instructions in this article, I was able to completely recompile liblinxdevice_rpi2.so from the sources found here: https://github.com/MakerHub/LINX/tree/master/LabVIEW/vi.lib/MakerHub/LINX/Firmware 
And also successfully add some new functions related to the i2c bus to the library.

0 Kudos
Message 7 of 12
(4,115 Views)

How do you do?

I cant compile my program too.

 

 

root@raspberrypi:~# gcc tcp_test.c -o tcp_test
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lgcc
/usr/lib/gcc/arm-poky-linux-gnueabi/4.9.2/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status

 

 

 
0 Kudos
Message 8 of 12
(3,432 Views)

Did you use C/C++ Development Tools for NI Linux Real-Time Eclipse Edition?
I do exact, as described in this article, an it is compiled with no problem.

0 Kudos
Message 9 of 12
(3,414 Views)

There is no description for LabVIEW 2020

0 Kudos
Message 10 of 12
(3,399 Views)