How to use android gcc generate libsqlite.so
+ 1) why should we build the sqlite library for ourself.
The reason is the android system libsqlite.so wouldn't implement some functions we needed(like func: sqlite3_prepare_v2), so we should generate a new libsqlite.so for ourself and use in our apps and games.
+ 2) Download the latest sqlite code from the website http://www.sqlite.org/;
unzip the package ,you will find three files, we will build sqlite3.c ,and you should add sqlite.h in your project if you want use the latest function.
+ 3) Build the sqlite.c by the android NDK gcc;
First, you should find the gcc file path,my computer gcc at :/opt/Android/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-gcc
PS: if X86 computer ,use x86 tools;
Then, generate -o file:
$ /opt/Android/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-gcc -c sqlite3.c --sysroot=/opt/Android/android-ndk-r7b/platforms/android-9/arch-arm/
Ok, at last,generate the .so file:
$ /opt/Android/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-gcc sqlite3.o -shared -o libsqlite.so --sysroot=/opt/Android/android-ndk-r7b/platforms/android-9/arch-arm
Ok, if everything work fine ,you will find you generate a libsqlite.so file at the current directory. And you can use your libsqlite.so in your android apps and games, really interesting, Happy!
PS: i should explain the gcc flag:--sysroot:
--sysroot: help us gcc to find the include header and link library, really useful. You don't need use -I to include the header, or use -L to link the needed library.Powerful!
Enjoy it !
浙公网安备 33010602011771号