/* ** name :testsqlite.c ** This file is used to test C/C++ API for sqlite ** Author : zieckey ** Date : 2006/04/11 */ #include<stdio.h> #include<sqlite3.h>
int main(void) { sqlite3 *db=NULL; char*zErrMsg = 0; int rc; rc =sqlite3_open("zieckey.db",&db);//打开指定的数据库文件,如果不存在将创建一个同名的数据库文件
@H_301_0@
bash-3.00# gcc testsqlite.c
testsqlite.c:8:21: sqlite3.h: 无此文件或目录
testsqlite.c: In function `main':
testsqlite.c:12: error: `sqlite3' undeclared (first use in this function)
testsqlite.c:12: error: (Each undeclared identifier is reported only once
testsqlite.c:12: error: for each function it appears in.)
testsqlite.c:12: error: `db' undeclared (first use in this function)
testsqlite.c:25:2: warning: no newline at end of file
bash-3.00# gcc testsqlite.c -lsqlite3
testsqlite.c:8:21: sqlite3.h: 无此文件或目录
testsqlite.c: In function `main':
testsqlite.c:12: error: `sqlite3' undeclared (first use in this function)
testsqlite.c:12: error: (Each undeclared identifier is reported only once
testsqlite.c:12: error: for each function it appears in.)
testsqlite.c:12: error: `db' undeclared (first use in this function)
testsqlite.c:25:2: warning: no newline at end of file
bash-3.00# gcc testsqlite.c -lsqlite3 -I.
testsqlite.c:25:2: warning: no newline at end of file
ld: 致命的: 库 -lsqlite3: 没有找到
ld: 致命的: 文件处理错误。无输出写到a.out
collect2: ld returned 1 exit status
bash-3.00# gcc testsqlite.c -lsqlite3 -I. -L.
testsqlite.c:25:2: warning: no newline at end of file
bash-3.00# ls
a.out libsqlite3.so shell.c sqlite3 sqlite3.c sqlite3.h testsqlite.c zieckey.db
bash-3.00# ./a.out
open zieckey.db successfully!
@H_301_0@
@H_301_0@
好了终于成功了!恭喜你!
@H_301_0@
@H_301_0@
关于上面的一些错误问题的解决办法的详细解释见“参考文档1”。
@H_301_0@
@H_301_0@
参考文档:
1、
http://blog.chinaunix.net/u/16292/showart_108145.html 2、
http://www.sqlite.org/cvstrac/wiki?p=HowToCompile