1、 下載SQLite 3.7.6.3,http://www.sqlite.org/sqlite-autoconf-3070603.tar.gz
2 、 解壓到某個檔案夾下
3 、 配置,這裡安裝到當前檔案夾下的sqlite下
./configure CC=/usr/local/arm/4.4.1/bin/arm-linux-gcc –prefix=./sqlite --disable-tcl --host=arm-linux
4 、make&&make install
在sqlite下產生bin include lib share檔案
5 、進入bin檔案,執行arm-linux-strip sqlite3
6 、將bin檔案下的sqlite3執行檔案拷至開發板bin檔案下,lib檔案夾下的所有檔案拷至開發板的/lib檔案夾下
7 、./sqlite3 列印如下
SQLite version 3.7.6.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
8 、編寫C測試
hello.c
#include<stdio.h><br />#include"sqlite3.h"<br />int main(void)<br />{<br /> const char *dbfile = "test.db";<br /> sqlite3 *pdb = NULL;<br /> int result;<br /> if ((result = sqlite3_open(dbfile, &pdb)) != 0)<br /> {<br /> printf("error: can't open %s/nerrmsg: %s/n", dbfile, sqlite3_errmsg(pdb));<br /> return -1;<br /> }<br /> else<br /> {<br /> printf("opened!/n");<br /> }<br /> if ((result = sqlite3_close(pdb)) != 0)<br /> {<br /> printf("error: can't close %s/nerrmsg: %s/n", dbfile, sqlite3_errmsg(pdb));<br /> return -1;<br /> }<br /> else<br /> {<br /> printf("closed!/n");<br /> }<br /> return 0;<br />}
將編譯產生的.so檔案拷至hello.c檔案夾下
arm-linux-gcc -o hello{,.c} -L$PWD -lsqlite3
將hello拷至開發板 ./hello
列印:
opened!
closed!
同時產生test.db檔案