java代码运行pi4j的例子报错(ubuntu mate64位系统)

小土豆 65cm2020-09-051166 次点击
xiaotudou@xiaotudou:~/data/test$ java -classpath .:classes:/opt/pi4j/lib/'*' LEDBreathingLight
Let's gogogogogoogo...Breathing~
Sep 05, 2020 2:21:15 PM com.pi4j.util.NativeLibraryLoader load
SEVERE: Unable to load [libpi4j.so] using path: [/lib/raspberrypi/dynamic/libpi4j.so]
java.lang.UnsatisfiedLinkError: /tmp/libpi4j1709006903530610670.so: /tmp/libpi4j1709006903530610670.so: wrong ELF class: ELFCLASS32
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at com.pi4j.util.NativeLibraryLoader.loadLibraryFromClasspath(NativeLibraryLoader.java:159)
at com.pi4j.util.NativeLibraryLoader.load(NativeLibraryLoader.java:105)
at com.pi4j.wiringpi.Gpio.<clinit>(Gpio.java:189)
at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:69)
at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:51)
at com.pi4j.platform.Platform.getGpioProvider(Platform.java:125)
at com.pi4j.platform.Platform.getGpioProvider(Platform.java:118)
at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:109)
at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:53)
at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:91)
at LEDBreathingLight.main(LEDBreathingLight.java:29)

Exception in thread "main" java.lang.UnsatisfiedLinkError: com.pi4j.wiringpi.Gpio.wiringPiSetup()I
at com.pi4j.wiringpi.Gpio.wiringPiSetup(Native Method)
at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:69)
at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:51)
at com.pi4j.platform.Platform.getGpioProvider(Platform.java:125)
at com.pi4j.platform.Platform.getGpioProvider(Platform.java:118)
at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:109)
at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:53)
at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:91)
at LEDBreathingLight.main(LEDBreathingLight.java:29)


以下是正常的类库什么的
xiaotudou@xiaotudou:/opt/pi4j/lib$ gpio -v
gpio version: 2.60
Copyright (c) 2012-2018 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Raspberry Pi Details:
Type: Pi 4B, Revision: 04, Memory: 0MB, Maker: Sony
* Device tree is enabled.
*--> Raspberry Pi 4 Model B Rev 1.4
* This Raspberry Pi supports user-level GPIO access.


xiaotudou@xiaotudou:/opt/pi4j/lib$ gpio readall
+-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | ALT0 | 1 | 3 || 4 | | | 5v | | |
| 3 | 9 | SCL.1 | ALT0 | 1 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | IN | 1 | 7 || 8 | 1 | ALT5 | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 1 | ALT5 | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | IN | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 0 | IN | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | ALT0 | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | ALT0 | 0 | 21 || 22 | 0 | IN | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | ALT0 | 0 | 23 || 24 | 1 | OUT | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 1 | OUT | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | IN | 1 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | IN | 1 | 31 || 32 | 0 | IN | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 0 | IN | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 0 | IN | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+
收藏 ♥ 感谢
Spoony 小组长 2020-09-05 
这类问题建议通过百度错误日志去找解决方法
小土豆 65cm 2020-09-05 
@Spoony 找了,没解决才来这的
小土豆 65cm 2020-09-05 
@Spoony 弄好了,改的源码,加载的*.so文件不是64位的原因。
Spoony 小组长 2020-09-05 
@小土豆 谢谢反馈
https://talk.quwj.com/topic/1471

登录注册 后可回复。

这里由以下店铺的技术人员在此免费提供能力范围内的技术支持。

NXEZ 创客商店(淘宝)

排障问题发帖注意事项:
1、请尽可能将故障说明清晰,列明例如使用环境和做了哪些操作和配置等。
2、排障中已经做了哪些尝试,如果能在问题中进行描述将极大提高解决问题的效率。
3、对于需要自身完成知识积累才能解决的问题,请自行通过搜索引擎寻找资料学习。