我们的团队尝试将pi4j -lib 捆绑为 OSGi 捆绑包以访问 Raspberry Pi 上的 GPIO,但我们得到一个UnsatisfiedLinkError
并且不知道这里发生了什么以及如何解决它。
我们将本机libpi4j.so
放在捆绑包的文件夹/lib
中,并指定MANIFEST.MF
如下:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Pi4j
Bundle-SymbolicName: com.pi4j
Bundle-Version: 1.0.0.SNAPSHOT
Bundle-Vendor: http://pi4j.com/
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-NativeCode: lib/libpi4j.so; osname=linux;processor=arm
Eclipse-PlatformFilter: (& (osgi.os=linux) (osgi.arch=arm))
Bundle-ClassPath: lib/, .
Export-Package: com.pi4j.concurrent,[.. some more packages]
这是错误消息:
!SESSION 2013-02-10 08:21:25.975 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.7.0_40
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=arm, WS=gtk, NL=de_DE
!ENTRY org.eclipse.osgi 4 0 2013-02-10 08:21:37.256
!MESSAGE Application error
!STACK 1
java.lang.UnsatisfiedLinkError: no libpi4j in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1878)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1087)
at com.pi4j.util.NativeLibraryUser.<clinit>(NativeLibraryUser.java:36)
at eu.gemtec.carepi.app.Application.start(Application.java:30)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
该类NativeLibraryUser
有一个调用System.loadLibrary("libpi4j")
来加载本机。本机存在于/lib
捆绑包的 -folder 中,因此这应该不是问题。这里发生了什么,为什么它不起作用?
如果我没记错的话,Equinox 会将本机解包到捆绑池以便加载它,但是我找不到我们的应用程序,这是一个问题吗?