I’m trying to get NetworkTables to work on a RaspberryPi. But the native libraries do not work. The NetworkTables-3.0.0-SNAPSHOT-arm.jar file contains a Linux.arm libntcore.so, but it will not load:
Exception in thread “main” java.lang.UnsatisfiedLinkError: /home/pi/libntcore.so: /home/pi/libntcore.so: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1814)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1083)
at org.usfirst.frc.team1294.vision.Application.main(Application.java:80)
Which pretty much means that the native binary was compiled for the architecture of the RoboRio, and is not compatible with the RaspberryPi.
I tried getting the NetworkTables source to compile on the RPi. But was getting too many errors that I did not understand.
Has anyone gotten NetworkTables to work on a RaspberryPi?
I am working on setting up a build server for a Raspberry Pi 2 build. It can be found here. http://198.199.94.5/ntcore/. Use the latest/arm-linux-gnueabihf/ binaries. Note this will only work with Pi 2’s. Pi 1’s are much harder to get working with.
Note to use this, you will need to grab the libstdc++.so.6, and set LD_LIBRARY_PATH to include the path that file is in before running your program. I have not actually tested this on a Pi 2, however I did test it on a BeagleBone Black and a CHIP and it worked on both. I will test the Pi 2 tonight.
The reason the RoboRIO libraries do not work is that the RoboRIO is Arm vfp, whereas Raspberry Pis and BeagleBone Blacks are Arm Hard Float.
If you are using Java, try the jar in the Java folder instead of the maven jar. That should have the ntcore library built in and automatically extract it.
If that doesn’t work, when you try and run the project, there should be a line that gets printed that starts with “Platform:”. What does that string say?
Looking at the source code again, it does look like you should just be able to put libntcore.so in /home/pi/. Does that work?
I created a new super simple java app to rule out anything else. I did not add any dependencies to NetworkTables. Inside my main method, I have a single line:
System.loadLibrary(“ntcore”);
I thought I was getting the identical error, on closer inspection, I am getting the following now:
Exception in thread “main” java.lang.UnsatisfiedLinkError: /home/pi/libntcore.so: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `CXXABI_1.3.9’ not found (required by /home/pi/libntcore.so)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1847)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at org.usfirst.frc.team1294.vision.Application.main(Application.java:14)
Ah. So to fix that, you need to download the libstdc++.so.6 in the ntcore folder. Place that in /home/pi/ on your Pi, and add this line to your program start command.
*env LD_PRELOAD=/home/pi/libstdc++.so.6 *. So your command to run would become env LD_PRELOAD=/home/pi/libstdc++.so.6 java myapp.jar, replacing myapp.jar with whatever your app is.
Is the native library necessary for NetworkTables to execute?
Previous year’s network table JAR did not contain native libraries. My latest copy of the jar contains an *.so file for Linux ARM, but none for any other operating systems or architectures.
Can we simply ignore this file? Or, can we just remove the native library from the JAR before deploying to a Raspberry Pi?
I get the same output too. Thats why you have to call LD_PRELOAD before you run your program. LD_PRELOAD allows you to specify a different library as the dependency. So if you LD_PRELOAD to the libstdc++.so.6 found here http://198.199.94.5/ntcore/libstdc++.so.6 it will load that one before trying to load the default one and should work.
But I still get the error. Is my syntax wrong? Is there yet another dependency that I need to preload? Is there something I need to install on my Pi in order for that environment variable to take effect?
Thank you so much for continuing to reply and not giving up on me!
D’oh… I already had a version of libstdc++.so.6 in my folder from some previous troubleshooting. When I did a wget on your version, it was not overwriting it for some reason. Gah… I feel like an idiot. Error resolved.
THANK YOU so much for spending so much time with me on this.
Hey guys!
I am currently trying to do what you were doing and was wondering how you were able to be successful. I was able to get NetworkTables working well in C++ but not Java. I try doing what you did where you loaded the ntcore library but I keep getting a NoClassDefFoundError.
Thanks! I really appreciate it!!