views:

72

answers:

2

I need to statically link the 3.6.2 version of SQLite against my android application due to a bug that affects the dynamic library bundled with Android < 2.2. I've already compiled and installed 3.6.2 on my development machine, but I'm not sure how I go about linking it to my Android app (developing with Eclipse).

I'm not familiar with building and compiling options, so if someone could walk me through step-by-step, it'd be much appreciated.

+1  A: 

SQLite builds "out of the box" using the Android NDK. Get the NDK, create a .mk file for SQLite with the options you desire and build.

NuSkooler
Hi, I'm getting errors when I run the ndk-build script. I copied the sqlite3.c and sqlite3.h files to my project's jni folder, created a simple .mk file and ran ndk-build. It returned with compilation errors about some undefined references. Sorry, I'm a complete noob when it comes to compiling. Thanks!
Without knowing the errors your getting, it's hard to respond here.
NuSkooler
Here's what I'm getting:Compile thumb : sqlite3 <= ###/eclipse/workspace/MyProject/jni/sqlite3.c###/eclipse/workspace/MyProject/jni/sqlite3.c: In function 'unixDlError':###/eclipse/workspace/MyProject/jni/sqlite3.c:26415: warning: assignment discards qualifiers from pointer target typeSharedLibrary : libsqlite3.so###/eclipse/workspace/MyProject/obj/local/armeabi/objs/sqlite3/sqlite3.o: In function `unixDlSym':###/eclipse/workspace/MyProject/jni/sqlite3.c:26442: undefined reference to `dlsym'
It looks like you need to link in libdl. E.g. in your LOCAL_LDLIBS: LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -ldl
NuSkooler
+1  A: 

Another option is to add the binary to assets and then unzip to /data/data/ and exec it from there.

Nick Palmer