Sqlite3 在 Linux 上的安装

//听说通常装在local下

[root@localhost sqlite-3.6.16]# cd /usr/local/
//拷贝
[root@localhost local]# cp /home/db/Download/sqlite-amalgamation-3.6.16.tar.gz /usr/local/

//解压.gz

[root@localhost local]# gunzip sqlite-amalgamation-3.6.16.tar.gz

//解压.tar

[root@localhost local]# tar -xf sqlite-amalgamation-3.6.16.tar
//改目录名,方便点,其实证实不在此目录下创建lib,bin,include....
[root@localhost local]# mv sqlite-3.6.16 sqlite3
[root@localhost local]# cd sqlite3

//.configure
[root@localhost sqlite3]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
...........
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sqlite3.pc
config.status: executing depfiles commands

//make

[root@localhost sqlite3]# make
if /bin/sh ./libtool --tag=CC --mode=compile gcc -DPACKAGE_NAME=/"sqlite/" -DPACKAGE_TARNAME=/"sqlite/"

................


//make install

[root@localhost sqlite3]# make install
make[1]: Entering directory `/usr/local/sqlite3'
test -z "/usr/local/lib" || mkdir -p -- "/usr/local/lib"
...................
Libraries have been installed in:
/usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory,LIBDIR,you must either use libtool,and
specify the full pathname of the library,or use the `-LLIBDIR'

flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
............................

//make doc 失败了,不知道是做什么用的。
[root@localhost sqlite3]# make doc
make: *** No rule to make target `doc'. Stop.
[root@localhost sqlite3]# cd /usr/local/sqlite3

//测试一下,创建test.db
[root@localhost sqlite3]# ./sqlite3 test.db
sqlite version 3.6.16
Enter ".help" for instructions
Enter sql statements terminated with a ";"

//不错,退出

sqlite> .exit

//编了个C程序调用sqlITE的功能,说是找不到LIB库文件

[root@localhost wisconsin]# gcc -o b b.c
/tmp/ccOs5aBm.o: In function `main':
b.c:(.text+0x2e): undefined reference to `sqlite3_open'
b.c:(.text+0x42): undefined reference to `sqlite3_errmsg'
b.c:(.text+0x67): undefined reference to `sqlite3_close'
b.c:(.text+0x80): undefined reference to `sqlite3_close'


//找个好久解决方法,但是发现MAKE时系统给出说明了,在上面的红色部分就是。简单说就是要用-L来指定库文件所在目录:

//下面代码可以编译通过了

[root@localhost sqlite3]# [root@localhost wisconsin]# gcc b.c -o b -L/usr/local/lib/ -lsqlite3

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能