寫了一個簡單的C測試程序,里面調有了幾個sqlite接口。然后編譯。我就試試如何編譯鏈接
程序目錄如下
/home/sqlite-ix86-linux
[root@localhost sqlite-ix86-linux]# ls
bin? ctest? huyi.db? include? lib? test? test.c
庫和頭文件都不是在標準的/usr/include 和/usr/lib目錄下
gcc -L/home/sqlite-ix86-linux/lib/ -lsqlite3 -o test test.c
編譯通過。其實后來把頭文件拷到了/usr/include 目錄下了。半天沒有搞對,就拷過去了。
運行test報
./test: error while loading shared libraries: libsqlite3.so.0: cannot open shared object file: No such file or directory
再到網上一查原來是加載動態鏈接庫的路徑不對
export LD_LIBRARY_PATH=/home/sqlite-ix86-linux/lib
運行成功了