【随笔记】NDK 编译开源库 SQLite3

NDK 编译环境搭建请参考:
【工作笔记】NDK 编译开源库 nghttp2/openssl/curl_lovemengx的博客-CSDN博客

一、下载源代码

wget https://github.com/sqlite/sqlite/archive/refs/tags/version-3.38.0.tar.gz
tar -zxvf version-3.38.0.tar.gz

二、编译配置脚本

#!/bin/bash

export TOOLCHAIN=/opt/ndk/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64
export CC="$TOOLCHAIN"/bin/armv7a-linux-androideabi19-clang 
export CXX="$TOOLCHAIN"/bin/armv7a-linux-androideabi19-clang++ 
export TOOL=arm-linux-androideabi
export LD=$TOOLCHAIN/bin/${TOOL}-ld
export AR=$TOOLCHAIN/bin/${TOOL}-ar
export RANLIB=$TOOLCHAIN/bin/${TOOL}-ranlib
export STRIP=$TOOLCHAIN/bin/${TOOL}-strip
export PATH="$TOOLCHAIN"/bin:"$PATH"
export ARCH_FLAGS="-mthumb"
export CFLAGS="${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector-all -fno-strict-aliasing"
export CXXFLAGS="${CFLAGS} -frtti -fexceptions"

./configure --prefix=`pwd`/build/sqlite3/ \
       --with-sysroot=$TOOLCHAIN/sysroot \
       --host=arm-linux-androideabi \
	   --enable-shared \
       --disable-static \
	   --disable-tcl
	   
if [ $? -eq 0 ]; then
	make -j16 && make install
fi

三、执行编译

cp android_build_sqlite3.sh sqlite-version-3.38.0/
cd sqlite-version-3.38.0
./android_build_sqlite3.sh

posted @ 2022-03-09 17:01  Love_梦想  阅读(94)  评论(0编辑  收藏  举报