首先,sqlite 官方已经有预编译好的DLL下载,如果你不需要特别优化的版本,直接下载官网上的DLL即可。你可以在下载 页面的 “Precompiled Binaries For Windows” 可以找到。
不过你想编译出自己的版本,比如添加优化参数后编译,debug版,或进行一些定制(例如官网这里 有一些预编译宏,允许你定制自己的sqlite),那么你就需要自己编译了。
首先在下载源代码,在页面的第一行就是,如 sqlite-amalgamation-3_7_3.zip ,得到sqlite3.def、sqlite3.c、sqlite3.h以及sqlite3ext.h,一般下拉到 “Precompiled Binaries For Windows” 就可以看到,例如 sqlitedll-3_7_3.zip 有多种不同版本的,这里 就不多说了。
然后解压 sqlite-amalgamation-3_6_12.zip 到文件夹 sqlite3/,会得到 sqlite3.c,sqlite3.h,sqlite3ext.h 三个文件,然后解压 sqlitedll-3_6_12.zip ,把 sqlite3.def 移动到 sqlite3/ 下面。
下面就是新建一个工程
1.打开VC新建一个“Win32 Dynamic-Link Library”工程,命名为:sqlite3;
2.在接下来的对话框中选择"An empty DLL project",点 FINISH->OK;
3.将得到的文件复制到工程文件夹下
4.在工程的Source Files