PI4J - 无法使用路径加载[libpi4j.so]

时间:2015-04-18 18:46:52

标签: java macos netbeans raspberry-pi pi4j

我在MacOS上使用NetBeans使用PI4J开发应用程序。一切看起来都不错,但我得到下面的错误,说PI4J无法加载。有谁知道如何解决这个问题?

abr 18, 2015 3:02:30 PM com.pi4j.util.NativeLibraryLoader load
SEVERE: Unable to load [libpi4j.so] using path: [/lib/libpi4j.so]
java.lang.UnsatisfiedLinkError: /private/var/folders/0x/6rph2scs0f544b7xwkfhzkcw0000gn/T/libpi4j3968879292977354112.so: dlopen(/private/var/folders/0x/6rph2scs0f544b7xwkfhzkcw0000gn/T/libpi4j3968879292977354112.so, 1): no suitable image found.  Did find:
    /private/var/folders/0x/6rph2scs0f544b7xwkfhzkcw0000gn/T/libpi4j3968879292977354112.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x01 0x01 0x01 0x00
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1937)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1822)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1086)
    at com.pi4j.util.NativeLibraryLoader.loadLibraryFromClasspath(NativeLibraryLoader.java:143)
    at com.pi4j.util.NativeLibraryLoader.load(NativeLibraryLoader.java:92)
    at com.pi4j.wiringpi.Gpio.<clinit>(Gpio.java:174)
    at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:51)
    at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:106)
    at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:54)
    at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:89)
    at hellorasp.HelloRasp.main(HelloRasp.java:31)

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:51)
    at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:106)
    at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:54)
    at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:89)
    at hellorasp.HelloRasp.main(HelloRasp.java:31)

3 个答案:

答案 0 :(得分:1)

/lib/libpi4j.so文件无效,因为它仅适用于Raspberry Pi,而不是任何其他硬件。

答案 1 :(得分:0)

将libpi4j.so复制到RPI上的项目lib文件夹

答案 2 :(得分:0)

假设OP在树莓派上运行他的代码,我在pi运行代码上也遇到了此错误,该代码控制了截至2018年2月工作的伺服系统,但在2018年7月产生了此确切错误。我发现pi4j 1.2发行版中发生了更改,需要您手动安装connectionpi库

所以我得到了确切的错误,按照以下说明进行操作,然后我的伺服系统又重新移动了:

http://wiringpi.com/download-and-install/