cl.exe 命令行编译sqlite3 sqlite3.dll及sqlite3.exe

有点被宇宙最强的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、直接编译

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.0\VC\bin

INCLUDE  = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\winrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\km;

LIB = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x86

3、编译dll

1
cl .\sqlite3.c -link -dll -out:sqlite3.dll

 4、编译exe

1
cl .\sqlite3.c  .\shell.c -link  -out:sqlite3.exe

 

 

5、编译选项

1
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.

posted @   愤怒的企鹅  阅读(621)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
点击右上角即可分享
微信分享提示