有点被宇宙最强的ide惯坏了,封装的太好,不能像gcc那样一步步了解其原理,其实强大的vs背后也有类似gcc的cl.exe
看到How To Compile SQLite
http://sqlite.org/howtocompile.html
想着自己编译下sqlite ,也可假如需要的一些特殊编译选项
下载amalgamation版本,就一个sqlite文件
http://www.sqlite.org/2018/sqlite-amalgamation-3230100.zip
1、直接编译
cl.exe sqlite3.c -link -dll -out:sqlite3.dll
报错:
'cl.exe' 不是内部或外部命令,也不是可运行的程序或批处理文件 -- 缺环境变量
sqlite3.c(1059): fatal error C1034: stdarg.h: 不包括路径集 需要配置include路径环境变量
2、添加环境变量
(cl也支持选项也支持指定 程序集、库、搜索路径 “ /I<dir> 添加到包含搜索路径” “/link [链接器选项和库]”,偷懒设置环境变量)参考:https://msdn.microsoft.com/zh-cn/library/x2khzsa1.aspx
我的是vs2013 :添加对应的path ,include,lib
设置环境变量:
PATH 添加 C:Program Files (x86)Microsoft Visual Studio 12.0VCin
INCLUDE = C:Program Files (x86)Microsoft Visual Studio 12.0VCinclude;C:Program Files (x86)Windows Kits10Include10.0.15063.0um;C:Program Files (x86)Windows Kits10Include10.0.15063.0;C:Program Files (x86)Windows Kits10Include10.0.15063.0shared;C:Program Files (x86)Windows Kits10Include10.0.15063.0ucrt;C:Program Files (x86)Windows Kits10Include10.0.15063.0winrt;C:Program Files (x86)Windows Kits10Include10.0.15063.0km;
LIB = C:Program Files (x86)Microsoft Visual Studio 12.0VClib;C:Program Files (x86)Windows Kits10Lib10.0.15063.0umx86
3、编译dll
cl .sqlite3.c -link -dll -out:sqlite3.dll
4、编译exe
cl .sqlite3.c .shell.c -link -out:sqlite3.exe
5、编译选项
cl .sqlite3.c .shell.c -Os -link -out:sqlite3.exe
-
-Os - Optimize for size. Make the DLL as small as possible.
-
-O2 - Optimize for speed. This will make the DLL larger by unrolling loops and inlining functions.
-
-DSQLITE_ENABLE_FTS4 - Include the full-text search engine code in SQLite.
-
-DSQLITE_ENABLE_RTREE - Include the R-Tree extension.
-
-DSQLITE_ENABLE_COLUMN_METADATA - This enables some extra APIs that are required by some common systems, including Ruby-on-Rails.