Compile Sqlite3 Executable, Static Library, and Shared Library on Linux

Download Sqlite3 source code, and decompress it to somewhere.

Enter the decompressed folder, type the following command to generate different targets with all features.

Executable

gcc -fPIC -Os -I. -DSQLITE_THREADSAFE=2 -DSQLITE_ENABLE_FTS4    -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_EXPLAIN_COMMENTS    -DHAVE_USLEEP -DHAVE_READLINE shell.c sqlite3.c -ldl -lm -lreadline -lncurses -lpthread -o sqlite34

Static Library

gcc -Os -I. -DSQLITE_THREADSAFE=2 -DSQLITE_ENABLE_FTS4    -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1    -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_EXPLAIN_COMMENTS    -DHAVE_USLEEP -DHAVE_READLINE sqlite3.c -fPIC -c -o sqlite34.o

ar rcs libsqlite34.a sqlite34.o

Shared Library

gcc -Os -I. -DSQLITE_THREADSAFE=2 -DSQLITE_ENABLE_FTS4    -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1    -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_EXPLAIN_COMMENTS    -DHAVE_USLEEP -DHAVE_READLINE sqlite3.c -ldl -lm -lreadline -lncurses -fPIC -lpthread -shared -o libsqlite34.so

posted on 2023-01-26 10:29  Bo Schwarzstein  阅读(65)  评论(0编辑  收藏  举报