xerial / sqlite-jdbc

SQLite JDBC Driver
Apache License 2.0
2.84k stars 619 forks source link

UnsatisfiedLinkError on ARM CORTEX A9 (soft float) at DB.open #45

Closed antonio-dibacco closed 9 years ago

antonio-dibacco commented 9 years ago

I used sqlite-jdbc-3.8.11.jar to compile a jar that tries to open a connection to a database. This is the error I get on a ARM CORTEX A9 (soft float). The same jar is working fine on Ubuntu on x86. I think that working on ARM is quite important for a library like this.

zynq> java -jar sqlite-3.8.11.jar Exception in thread "main" java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open(Ljava/lang/String;I)V at org.sqlite.core.NativeDB._open(Native Method) at org.sqlite.core.DB.open(DB.java:161) at org.sqlite.core.CoreConnection.open(CoreConnection.java:220) at org.sqlite.core.CoreConnection.(CoreConnection.java:76) at org.sqlite.jdbc3.JDBC3Connection.(JDBC3Connection.java:24) at org.sqlite.jdbc4.JDBC4Connection.(JDBC4Connection.java:23) at org.sqlite.SQLiteConnection.(SQLiteConnection.java:45) at org.sqlite.JDBC.createConnection(JDBC.java:114) at org.sqlite.JDBC.connect(JDBC.java:88) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at com.argonnetech.sqlite.SQLite.main(SQLite.java:14)

xerial commented 9 years ago

Could you try make native and mvn test command? If it works, please send the generated native library src/main/resources/org/sqlite/native/Linux/arm/libsqlitejdbc.so so that we can properly support ARM CPU.

Thanks.

antonio-dibacco commented 9 years ago

Hi Taro,

I did what you suggested. It seems to work. Then, probably I can use what I've produced for my application.

parallels@ubuntu:~/ypacket2/rootfs/packages/sqlite-jdbc$ make native CROSS_PREFIX=arm-xilinx-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm perl -p -e "s/sqlite3_api;/sqlite3_api = 0;/g" \ target/sqlite-amalgamation-3081100/sqlite3ext.h > target/sqlite-3.8.11-Linux-arm/sqlite3ext.h perl -p -e "s/^opendb_out:/ if(!db->mallocFailed && rc==SQLITE_OK){ rc = RegisterExtensionFunctions(db); }\nopendbout:/;" \ target/sqlite-amalgamation-3081100/sqlite3.c > target/sqlite-3.8.11-Linux-arm/sqlite3.c cat src/main/ext/.c >> target/sqlite-3.8.11-Linux-arm/sqlite3.c arm-xilinx-linux-gnueabi-gcc -o target/sqlite-3.8.11-Linux-arm/sqlite3.o -c -Itarget/sqlite-3.8.11-Linux-arm -Itarget/sqlite-amalgamation-3081100 -I/usr/lib/jvm/java-8-oracle/include -Ilib/inc_linux -O2 -mfloat-abi=softfp -mfpu=vfp -fPIC -fvisibility=hidden -I"/usr/lib/jvm/java-8-oracle/include" -I"/usr/lib/jvm/java-8-oracle/include/linux" \ -DSQLITE_ENABLE_LOAD_EXTENSION=1 \ -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \ -DSQLITE_ENABLE_COLUMN_METADATA \ -DSQLITE_CORE \ -DSQLITE_ENABLE_FTS3 \ -DSQLITE_ENABLE_FTS3_PARENTHESIS \ -DSQLITE_ENABLE_RTREE \ -DSQLITE_ENABLE_STAT2 \ \ target/sqlite-3.8.11-Linux-arm/sqlite3.c "$JAVA_HOME/bin/javac" -source 1.5 -target 1.5 -sourcepath src/main/java -d target/sqlite-3.8.11-Linux-arm src/main/java/org/sqlite/core/NativeDB.java warning: [options] bootstrap class path not set in conjunction with -source 1.5 warning: [options] source value 1.5 is obsolete and will be removed in a future release warning: [options] target value 1.5 is obsolete and will be removed in a future release warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. 4 warnings "$JAVA_HOME/bin/javah" -classpath target/sqlite-3.8.11-Linux-arm -jni -o target/sqlite-3.8.11-Linux-arm/NativeDB.h org.sqlite.core.NativeDB arm-xilinx-linux-gnueabi-gcc -Itarget/sqlite-3.8.11-Linux-arm -Itarget/sqlite-amalgamation-3081100 -I/usr/lib/jvm/java-8-oracle/include -Ilib/inc_linux -O2 -mfloat-abi=softfp -mfpu=vfp -fPIC -fvisibility=hidden -I"/usr/lib/jvm/java-8-oracle/include" -I"/usr/lib/jvm/java-8-oracle/include/linux" -c -o target/sqlite-3.8.11-Linux-arm/NativeDB.o src/main/java/org/sqlite/core/NativeDB.c arm-xilinx-linux-gnueabi-gcc -Itarget/sqlite-3.8.11-Linux-arm -Itarget/sqlite-amalgamation-3081100 -I/usr/lib/jvm/java-8-oracle/include -Ilib/inclinux -O2 -mfloat-abi=softfp -mfpu=vfp -fPIC -fvisibility=hidden -I"/usr/lib/jvm/java-8-oracle/include" -I"/usr/lib/jvm/java-8-oracle/include/linux" -o target/sqlite-3.8.11-Linux-arm/libsqlitejdbc.so target/sqlite-3.8.11-Linux-arm/.o -shared -static-libgcc arm-xilinx-linux-gnueabi-strip target/sqlite-3.8.11-Linux-arm/libsqlitejdbc.so cp target/sqlite-3.8.11-Linux-arm/libsqlitejdbc.so src/main/resources/org/sqlite/native/Linux/arm/libsqlitejdbc.so cp target/sqlite-3.8.11-Linux-arm/libsqlitejdbc.so target/classes/org/sqlite/native/Linux/arm/libsqlitejdbc.so parallels@ubuntu:~/ypacket2/rootfs/packages/sqlite-jdbc$ mvn test [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building SQLite JDBC [INFO] task-segment: [test] [INFO] ------------------------------------------------------------------------ [INFO] [enforcer:enforce {execution: enforce-maven}] [INFO] [resources:resources {execution: default-resources}] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 44 resources [INFO] Copying 10 resources [INFO] Copying 1 resource to META-INF/services [INFO] Copying 3 resources to META-INF/maven/org.xerial/sqlite-jdbc [INFO] [compiler:compile {execution: default-compile}] [INFO] Changes detected - recompiling the module! [INFO] Compiling 43 source files to /home/parallels/ypacket2/rootfs/packages/sqlite-jdbc/target/classes [WARNING] /home/parallels/ypacket2/rootfs/packages/sqlite-jdbc/src/main/java/org/sqlite/jdbc4/JDBC4PreparedStatement.java: Some input files use or override a deprecated API. [WARNING] /home/parallels/ypacket2/rootfs/packages/sqlite-jdbc/src/main/java/org/sqlite/jdbc4/JDBC4PreparedStatement.java: Recompile with -Xlint:deprecation for details. [INFO] [resources:testResources {execution: default-testResources}] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 2 resources [INFO] skip non existing resourceDirectory /home/parallels/ypacket2/rootfs/packages/sqlite-jdbc/src/test/resources [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] Changes detected - recompiling the module! [INFO] Compiling 23 source files to /home/parallels/ypacket2/rootfs/packages/sqlite-jdbc/target/test-classes [WARNING] /home/parallels/ypacket2/rootfs/packages/sqlite-jdbc/src/test/java/org/sqlite/PrepStmtTest.java: /home/parallels/ypacket2/rootfs/packages/sqlite-jdbc/src/test/java/org/sqlite/PrepStmtTest.java uses or overrides a deprecated API. [WARNING] /home/parallels/ypacket2/rootfs/packages/sqlite-jdbc/src/test/java/org/sqlite/PrepStmtTest.java: Recompile with -Xlint:deprecation for details. [INFO] [surefire:test {execution: default-test}] [INFO] Surefire report directory: /home/parallels/ypacket2/rootfs/packages/sqlite-jdbc/target/surefire-reports


T E S T S

Running org.sqlite.SQLiteConnectionPoolDataSourceTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.13 sec Running org.sqlite.StatementTest Tests run: 32, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.047 sec Running org.sqlite.JDBCTest Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec Running org.sqlite.UDFTest Tests run: 16, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.203 sec Running org.sqlite.SQLiteDataSourceTest Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec Running org.sqlite.ConnectionTest Tests run: 20, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.028 sec Running org.sqlite.DBMetaDataTest Tests run: 27, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.04 sec Running org.sqlite.SQLiteJDBCLoaderTest Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec Running org.sqlite.ResultSetTest Tests run: 13, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.009 sec Running org.sqlite.FetchSizeTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 sec Running org.sqlite.BackupTest Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.067 sec Running org.sqlite.ExtensionTest Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec Running org.sqlite.util.OSInfoTest Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec Running org.sqlite.ExtendedCommandTest Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec Running org.sqlite.SQLiteConfigTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec Running org.sqlite.QueryTest Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec Running org.sqlite.SavepointTest running in native mode Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.034 sec Running org.sqlite.PrepStmtTest Tests run: 28, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.045 sec Running org.sqlite.ReadUncommittedTest Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec Running org.sqlite.RSMetaDataTest Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec Running org.sqlite.TransactionTest running in native mode Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.085 sec Running org.sqlite.InsertQueryTest Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.06 sec

Results :

Tests run: 194, Failures: 0, Errors: 0, Skipped: 1

[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 8 seconds [INFO] Finished at: Mon Aug 03 08:49:58 PDT 2015 [INFO] Final Memory: 33M/300M [INFO] ------------------------------------------------------------------------ parallels@ubuntu:~/ypacket2/rootfs/packages/sqlite-jdbc$

antonio-dibacco commented 9 years ago

I did it, you can find the library attached.

Going to try this native lib. I will simply update the lib in the jar and let you know.

Thx.

On 3 August 2015 at 17:17, Taro L. Saito notifications@github.com wrote:

Could you try make native and mvn test command? If it works, please send the generated native library src/main/resources/org/sqlite/native/Linux/arm/libsqlitejdbc.so so that we can properly support ARM CPU.

Thanks.

— Reply to this email directly or view it on GitHub https://github.com/xerial/sqlite-jdbc/issues/45#issuecomment-127274576.

antonio-dibacco commented 9 years ago

I replaced the native arm lib into the jar with the one I compiled. I can open the database now, I will continue with other tests as well.

Thx very much.

xerial commented 9 years ago

@antonio-dibacco It looks like GitHub does not accept attachment via e-mail. Could you create a pull request with the native library you built, or directly send an e-mail to me (leo at xerial.org)?

Thanks.

xerial commented 9 years ago

Added your binary here: https://github.com/xerial/sqlite-jdbc/commit/3ee51f9b4db5ecfe56d75e7bd963c3d40c8112b8

Thanks for the contribution.

xerial commented 9 years ago

@antonio-dibacco Released 3.8.11.1 with your binary. Could you check whether this works or not? Thanks

antonio-dibacco commented 9 years ago

It works.

On 4 August 2015 at 05:02, Taro L. Saito notifications@github.com wrote:

@antonio-dibacco https://github.com/antonio-dibacco Released 3.8.11.1 with your binary. Could you check whether this works or not? Thanks

— Reply to this email directly or view it on GitHub https://github.com/xerial/sqlite-jdbc/issues/45#issuecomment-127461858.

xerial commented 9 years ago

Great. Thanks!

antonio-dibacco commented 9 years ago

Thanks to you for your wonderful work. Count on me for any test in the future.

Regards, Antonio.

On 4 August 2015 at 09:47, Taro L. Saito notifications@github.com wrote:

Great. Thanks!

— Reply to this email directly or view it on GitHub https://github.com/xerial/sqlite-jdbc/issues/45#issuecomment-127509619.

stefano055415 commented 9 years ago

hello , I have the same problem but with a ARMv5 , may you help me?

stefano055415 commented 9 years ago

I tried to compile with "make native".

perl -p -e "s/sqlite3_api;/sqlite3_api = 0;/g" \ target/sqlite-amalgamation-3081100/sqlite3ext.h > target/sqlite-3.8.11--/sqlite3ext.h perl -p -e "s/^opendb_out:/ if(!db->mallocFailed && rc==SQLITE_OK){ rc = RegisterExtensionFunctions(db); }\nopendbout:/;" \ target/sqlite-amalgamation-3081100/sqlite3.c > target/sqlite-3.8.11--/sqlite3.c cat src/main/ext/.c >> target/sqlite-3.8.11--/sqlite3.c o target/sqlite-3.8.11--/sqlite3.o -c -Itarget/sqlite-3.8.11-- -Itarget/sqlite-amalgamation-3081100 \ -DSQLITE_ENABLE_LOAD_EXTENSION=1 \ -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \ -DSQLITE_ENABLE_COLUMN_METADATA \ -DSQLITE_CORE \ -DSQLITE_ENABLE_FTS3 \ -DSQLITE_ENABLE_FTS3_PARENTHESIS \ -DSQLITE_ENABLE_RTREE \ -DSQLITE_ENABLE_STAT2 \ \ target/sqlite-3.8.11--/sqlite3.c make: o: Command not found Makefile:49: recipe for target 'target/sqlite-3.8.11--/sqlite3.o' failed make: [target/sqlite-3.8.11--/sqlite3.o] Error 127 (ignored) "$JAVAHOME/bin/javac" -source 1.5 -target 1.5 -sourcepath src/main/java -d target/sqlite-3.8.11-- src/main/java/org/sqlite/core/NativeDB.java /bin/sh: 1: /home/stefano/jre/bin/java/bin/javac: not found Makefile:34: recipe for target 'target/sqlite-3.8.11--/org/sqlite/core/NativeDB.class' failed make: ** [target/sqlite-3.8.11--/org/sqlite/core/NativeDB.class] Error 2

xerial commented 9 years ago

This error message says javac is not found. Please set: export JAVA_HOME=(your jdk installation path)

stefano055415 commented 9 years ago

ejdk (soft float) does not include javac and this is the only available for ARMv5.

xerial commented 9 years ago

I'm not familiar with embedded jdk. Could you tell me how do you compile java programs in ARMv5 machine?

stefano055415 commented 9 years ago

the problem is just that. I do not know if you can do and how to do it

stefano055415 commented 9 years ago

OK I have compiled, but I have this error

#

A fatal error has been detected by the Java Runtime Environment:

#

Internal Error (os_linux_zero.cpp:285), pid=3078, tid=3060642912

fatal error: caught unhandled signal 4

#

JRE version: OpenJDK Runtime Environment (7.0_79-b14) (build 1.7.0_79-b14)

Java VM: OpenJDK Zero VM (24.79-b02 mixed mode linux-arm )

Derivative: IcedTea 2.5.6

Distribution: Debian GNU/Linux 8.1 (jessie), package 7u79-2.5.6-1~deb8u1

Core dump written. Default location: /home/core or core.3078

#

An error report file with more information is saved as:

/home/hs_err_pid3078.log

#

If you would like to submit a bug report, please include

instructions on how to reproduce the bug and visit:

http://icedtea.classpath.org/bugzilla

The crash happened outside the Java Virtual Machine in native code.

See problematic frame for where to report the bug.

# Aborted (core dumped)

zhangguangkuan commented 4 years ago

Hello, have the above arm questions been released on a version?