Forum Stats

  • 3,837,134 Users
  • 2,262,229 Discussions
  • 7,900,211 Comments

Discussions

"JNI : Linux java.lang.UnsatisfiedLinkError

846238
846238 Member Posts: 9
edited Jun 6, 2011 11:30PM in Java Native Interface (JNI)
Hi All,



My bundles use JNI to communicate to the native code.

My native code further uses Sqlite3 libraries.



Please let me know how to link the the libraries:

Command I have used to generate the JNI shared library:

1.

gcc -I/java/jdk/include -I/java/jdk/include/genunix -c DbOperations.c -o DbOperations.o

ld -shared -f /usr/lib/libuuid.so DbOperations.o -o DbNativeInterface.so



2.

gcc -o libDbNativeInterface.so -shared -Wl,-soname,DbNativeInterface.so

-I /usr/lib/jvm/java-6-sun-1.6.0.22/include/

-I /usr/lib/jvm/java-6-sun-1.6.0.22/include/linux/ -I /<My path to>/SQLite/inc/ DbOperation.c



Using this so file in the bundle throws following error:

Couldn't start bundle: DataAccess (#22) (due to: java.lang.UnsatisfiedLinkError:

/home/user/knopflerfish_osgi_sdk_3.0.0/osgi/fwdir/bs/22/jar0/libDbNativeInterface.so:

/home/user/knopflerfish_osgi_sdk_3.0.0/osgi/fwdir/bs/22/jar0/libDbNativeInterface.so: undefined symbol: sqlite3_open)

java.lang.UnsatisfiedLinkError: /home/user/knopflerfish_osgi_sdk_3.0.0/osgi/fwdir/bs/22/jar0/libDbNativeInterface.so:

/home/user/knopflerfish_osgi_sdk_3.0.0/osgi/fwdir/bs/22/jar0/libDbNativeInterface.so: undefined symbol: sqlite3_open



Please guide with solutions or suggestions if any

Thank you

Vinay

Answers

  • 802316
    802316 Member Posts: 532
    Are you sure the sqllite shared library is being loaded? Where have you included it in the command line?
  • 846238
    846238 Member Posts: 9
    Hi,

    Yes, as you have noticed I have not include that in the command line. But, I have also tried the following command:

    gcc -o libDbNativeInterface.so -shared -Wl,-soname,DbNativeInterface.so -I /usr/lib/jvm/java-6-sun-1.6.0.22/include/ -I /usr/lib/jvm/java-6-sun-1.6.0.22/include/linux/ -I /home/user/VW_Sqlite_Test/SQLite/inc/ DbOperation.c -L /home/user/VW_Sqlite_Test/SqliteDynamicLib/libsqlitejdbc.so

    I don't know if I'm doing right. Please correct me.

    Thanks
    Vinay
This discussion has been closed.