Raspberry Pi上的Sqlite4java

我想在Raspberry Pi上使用我的java项目.此代码依赖于sqlite4java,它使用包括arm处理器link在内的许多平台的本机实现.问题是java无法为arm处理器加载所需的sqlite包装器.我正在做以下事情:复制所有版本(逐个尝试)...

我想在Raspberry Pi上使用我的java项目.此代码依赖于sqlite4java,它使用包括arm处理器link在内的许多平台的本机实现.

问题是java无法为arm处理器加载所需的sqlite包装器.我正在做以下事情:

>复制所有版本(逐个尝试)的预编译库(libsqlite4java-linux-armv5te.so,libsqlite4java-linux-armv7a.so,libsqlite4java-linux-arm.so),我将其重命名为libsqlite4java-linux-arm.so.
>命令java -Djava.library.path =. -jar sqlite4java.jar -d给出输出:

140213:092447.509 FINE [sqlite] Internal: loading library
140213:092447.536 FINE [sqlite] Internal: java.library.path=.
140213:092447.538 FINE [sqlite] Internal: sqlite4java.library.path=null
140213:092447.541 FINE [sqlite] Internal: cwd=/home/pi/sqlite4java-282/.
140213:092447.544 FINE [sqlite] Internal: default path=/home/pi/sqlite4java-282
140213:092447.554 FINE [sqlite] Internal: forced path=null 
140213:092447.558 FINE [sqlite] Internal: os.name=linux; os=linux
140213:092447.562 FINE [sqlite] Internal: os.arch=arm
140213:092447.575 FINE [sqlite] Internal: trying to load sqlite4java-linux-arm from /home/pi/sqlite4java-282/libsqlite4java-linux-arm.so
140213:092447.596 FINE [sqlite] Internal: cannot load sqlite4java-linux-arm from /home/pi/sqlite4java-282/libsqlite4java-linux-arm.so: java.lang.UnsatisfiedLinkError: /home/pi/sqlite4java-282/libsqlite4java-linux-arm.so: /home/pi/sqlite4java-282/libsqlite4java-linux-arm.so: cannot open shared object file: No such file or directory
140213:092447.605 FINE [sqlite] Internal: trying to load sqlite4java-linux-arm
140213:092447.617 FINE [sqlite] Internal: cannot load sqlite4java-linux-arm: java.lang.UnsatisfiedLinkError: /home/pi/sqlite4java-282/libsqlite4java-linux-arm.so: /home/pi/sqlite4java-282/libsqlite4java-linux-arm.so: cannot open shared object file: No such file or directory
140213:092447.622 FINE [sqlite] Internal: trying to load sqlite4java-linux
140213:092447.627 FINE [sqlite] Internal: cannot load sqlite4java-linux: java.lang.UnsatisfiedLinkError: no sqlite4java-linux in java.library.path
140213:092447.638 FINE [sqlite] Internal: trying to load sqlite4java
140213:092447.642 FINE [sqlite] Internal: cannot load sqlite4java: java.lang.UnsatisfiedLinkError: no sqlite4java in java.library.path
140213:092447.645 FINE [sqlite] Internal: trying to load sqlite4java-linux-arm-d
140213:092447.660 FINE [sqlite] Internal: cannot load sqlite4java-linux-arm-d: java.lang.UnsatisfiedLinkError: no sqlite4java-linux-arm-d in java.library.path
140213:092447.676 FINE [sqlite] Internal: trying to load sqlite4java-linux-d
140213:092447.680 FINE [sqlite] Internal: cannot load sqlite4java-linux-d: java.lang.UnsatisfiedLinkError: no sqlite4java-linux-d in java.library.path
140213:092447.683 FINE [sqlite] Internal: trying to load sqlite4java-d
140213:092447.699 FINE [sqlite] Internal: cannot load sqlite4java-d: java.lang.UnsatisfiedLinkError: no sqlite4java-d in java.library.path
Error: cannot load SQLite
java.lang.UnsatisfiedLinkError: /home/pi/sqlite4java-282/libsqlite4java-linux-arm.so: /home/pi/sqlite4java-282/libsqlite4java-linux-arm.so: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1957)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1882)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1843)
at java.lang.Runtime.load0(Runtime.java:795)
at java.lang.System.load(System.java:1061)
at com.almworks.sqlite4java.Internal.tryLoadFromPath(Internal.java:337)
at com.almworks.sqlite4java.Internal.loadLibraryX(Internal.java:117)
at com.almworks.sqlite4java.SQLite.main(SQLite.java:368)

>尝试将LD_LIBRARY_PATH设置为/usr/lib / arm-linux-gnueabihf和/usr/lib

在给定的路径文件存在.我安装了sqlite3和libsqlite3-dev.我在QEMU模拟器上使用最新的raspbian发行版:

$uname -a
$Linux raspberrypi 3.10.26+ #2 Fri Jan 17 22:13:59 EST 2014 armv6l GNU/Linux

任何帮助都会有用.

谢谢!

解决方法:

最后我找到了解决方案我不得不在Raspbian上构建库文件.
以下是步骤:

>从here获取资源
>从here获取sqlite_wrap.c文件
>将sqlite_wrap.c放入sources目录.你需要native,sqlite目录和sqlite_wrap.c文件.
>使用内容创建RELEASE文件:

#gcc
gcc -O2 -DNDEBUG -fpic -DARM -DARCH="ARM" -DLINUX -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_LITTLE_ENDIAN -fno-omit-frame-pointer -fno-strict-aliasing -static-libgcc -I./sqlite -I/usr/lib/jvm/jdk-7-oracle-armhf/include -I/usr/lib/jvm/jdk-7-oracle-armhf/include/linux -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT2 -DHAVE_READLINE=0 -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DTEMP_STORE=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_OMIT_DEPRECATED -DSQLITE_OS_UNIX=1 -c ./sqlite/sqlite3.c -o sqlite3.o
gcc -O2 -DNDEBUG -fpic -DARM -DARCH="ARM" -DLINUX -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_LITTLE_ENDIAN -fno-omit-frame-pointer -fno-strict-aliasing -static-libgcc -I./sqlite -I/usr/lib/jvm/jdk-7-oracle-armhf/include -I/usr/lib/jvm/jdk-7-oracle-armhf/include/linux -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT2 -DHAVE_READLINE=0 -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DTEMP_STORE=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_OMIT_DEPRECATED -DSQLITE_OS_UNIX=1 -c sqlite_wrap.c -o sqlite_wrap.o
gcc -O2 -DNDEBUG -fpic -Di586 -DARCH="i586" -DLINUX -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_LITTLE_ENDIAN -fno-omit-frame-pointer -fno-strict-aliasing -static-libgcc -I./sqlite -I./native -I/usr/lib/jvm/jdk-7-oracle-armhf/include -I/usr/lib/jvm/jdk-7-oracle-armhf/include/linux -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT2 -DHAVE_READLINE=0 -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DTEMP_STORE=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_OMIT_DEPRECATED -DSQLITE_OS_UNIX=1 -c ./native/sqlite3_wrap_manual.c -o sqlite3_wrap_manual.o
gcc -O2 -DNDEBUG -fpic -Di586 -DARCH="i586" -DLINUX -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_LITTLE_ENDIAN -fno-omit-frame-pointer -fno-strict-aliasing -static-libgcc -I./sqlite -I./native -I/usr/lib/jvm/jdk-7-oracle-armhf/include -I/usr/lib/jvm/jdk-7-oracle-armhf/include/linux -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT2 -DHAVE_READLINE=0 -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DTEMP_STORE=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_OMIT_DEPRECATED -DSQLITE_OS_UNIX=1 -c ./native/intarray.c -o intarray.o
gcc -O2 -DNDEBUG -fpic -Di586 -DARCH="i586" -DLINUX -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_LITTLE_ENDIAN -fno-omit-frame-pointer -fno-strict-aliasing -static-libgcc -shared -mno-cygwin -Wl,-soname=libsqlite4java-linux-arm.so -o libsqlite4java-linux-arm.so sqlite3.o sqlite_wrap.o sqlite3_wrap_manual.o intarray.o

> chmod x RELEASE并运行它./RELEASE.
>将构建libsqlite4java-linux-arm.so,您需要将其复制到应用程序的正确路径中.

本文标题为:Raspberry Pi上的Sqlite4java

基础教程推荐