sqlite3.44.2的编译

文章目录

sqlite3.44.2的编译

概述

想从源码编译一份Sqlite3.44.2出来.

编译sqlite3.44.2前置需要的TCL环境已经编译出来到了, 做了笔记(TCL - 库编译过程和官方手册).

前几次编译sqlite3.44.2时, 中间有部分报错, 但是也能编译出来.

看到作者的说明, 说看到编译中的警告不要怕, 因为作者使用全覆盖测试进行验证的, 保证没问题...

想确认正确的编译过程.

笔记

sqlite源码库镜像 https://github.com/sqlite/sqlite.git

迁出到本地 D:\3rd_prj\sqlite

查看版本地图, 回到3.44.2版本的发布版

README.md, 大概看看官方推荐的编译过程.

看Makefile.msc, 详细的了解如何编译.

主要是官方说明对于如何编译, 说的不详细. 自己看Makefile.msc就了解的比较清楚.

要指定编译的参数TCLDIR为 D:\TCL

需要在编译时, 指定要使用的TCL库的尾坠TCLSUFFIX为t

要指定编译的参数TCLSH_CMD为 tclsh86t.exe

试试

bash 复制代码
打开vs2019本地x64命令行

# 清屏
cls

# 将代码页改回美国
# https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chcp
chcp 437

# 查看当前激活的代码页
chcp

# 将自己编译的TCL目录加到临时PATH变量的前面
set path=D:\TCL;%path%

# 进入sqlite3.44.2的源码目录
cd /d D:\3rd_prj\sqlite

# 清除编译
# nmake /f Makefile.msc clean
nmake /f Makefile.msc moreclean

# 修正shell.c.cin 9462行的不可见字符, 删掉, 否则编译报错.

# 开始编译 - 主程序
nmake /f Makefile.msc all TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc dll TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc shell TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t

# 测试程序
nmake /f Makefile.msc testfixture.exe TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc sqlite3_analyzer.exe TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc sqlite3_checker.exe TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc sqldiff.exe TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc dbhash.exe TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc sqltclsh.exe TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t

nmake /f Makefile.msc coretestprogs TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t

# 快速测试
# 这个用的时间也很长, 让官方来保证吧
# nmake /f Makefile.msc quicktest TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t

# 生成所有测试程序并测试, 这步时间非常长(几个小时), 如果不是想得到测试程序, 不要做这步.
# 或者改一下Makefile.msc, 只生成测试程序, 不进行测试.
# 这个alltest经过8个小时都测试不完, 所以不能进行这个测试, 由官方来保证就行了
# nmake /f Makefile.msc alltest TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t

编译报错

这个是shell.c从shell.in转出来时出的错.

不管是回到git头, 还是release, 还是release 3.44.2 产生的 shell.c的那行都有乱码

单独产生shell.c

bash 复制代码
nmake /f Makefile.msc shell.c TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t

尝试在chcp 437下, 将TCL重新编译一次. 再重新开命令行来编译sqlite3.44.2的源码工程.

还是一样有这个报错, 编译不下去了.

解决shell.c编译报错的方法

shell.c 是从shell.c.in来的.

在src\shell.c.cin的9462行xbf后面有个不可见字符, 删掉.

用vscode打开时, 可以看到不可见字符

整理 - 正常可用的编译脚本过程

确保TCL已经正常编译过了, 且编译出的库已经改名, 笔记 : TCL - 库编译过程和官方手册

bash 复制代码
打开vs2019本地x64命令行

# 清屏
cls

# 将代码页改回美国
# https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chcp
chcp 437

# 查看当前激活的代码页
chcp

# 将自己编译的TCL目录加到临时PATH变量的前面
set path=D:\TCL;%path%

# 进入sqlite3.44.2的源码目录
cd /d D:\3rd_prj\sqlite

# 清除编译
# nmake /f Makefile.msc clean
nmake /f Makefile.msc moreclean

# 修正shell.c.cin 9462行的不可见字符, 删掉, 否则编译报错.

# 开始编译 - 主程序
nmake /f Makefile.msc all TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc dll TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc shell TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t

# 测试程序
nmake /f Makefile.msc testfixture.exe TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc sqlite3_analyzer.exe TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc sqlite3_checker.exe TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc sqldiff.exe TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc dbhash.exe TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t
nmake /f Makefile.msc sqltclsh.exe TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t

nmake /f Makefile.msc coretestprogs TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t

# 快速测试
# 这个用的时间也很长, 让官方来保证吧
# nmake /f Makefile.msc quicktest TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t

# 生成所有测试程序并测试, 这步时间非常长(几个小时), 如果不是想得到测试程序, 不要做这步.
# 或者改一下Makefile.msc, 只生成测试程序, 不进行测试.
# 这个alltest经过8个小时都测试不完, 所以不能进行这个测试, 由官方来保证就行了
# nmake /f Makefile.msc alltest TCLDIR=D:\TCL TCLSH_CMD=D:\TCL\bin\tclsh86t.exe TCLSUFFIX=t

剩下的事情

将头文件, 库文件, dll, exe都拷贝到单独的发布目录备用.

因为 Makefile.msc中, 并没有一个类似install的操作, 所以需要自己整理输出文件到发布目录.

bash 复制代码
Folder PATH listing
Volume serial number is 6CC8-4321
E:.
|   readme.txt
|   
+---bin
|       dbhash.exe
|       lemon.exe
|       mkkeywordhash.exe
|       mksourceid.exe
|       sqldiff.exe
|       sqlite3.dll
|       sqlite3.exe
|       sqlite3_analyzer.exe
|       sqlite3_checker.exe
|       sqltclsh.exe
|       src-verify.exe
|       tcl86t.dll
|       testfixture.exe
|       zlib1.dll
|       
+---demo
|       shell.c
|       
+---inc
|       sqlite3.h
|       sqlite3ext.h
|       
\---lib
        libsqlite3.lib
        sqlite3.lib

验证编译出的输出是否可以给工程正常使用?

新建一个控制台工程, 将shell.c作为实现. 在shell.c的开头包含sqlite3.lib

将mySqlite3442丢进工程, 设置好包含目录, 库路径.

在输出目录添加上sqlite3.dll

可以正常编译, 运行.

bash 复制代码
Folder PATH listing
Volume serial number is 36AD-51CE
D:.
|   shell.c
|   TestSqlite3442Include.sln
|   TestSqlite3442Include.vcxproj
|   TestSqlite3442Include.vcxproj.filters
|   TestSqlite3442Include.vcxproj.user
|   tree.txt
|   
+---mySqlite3442
|   |   readme.txt
|   |   
|   +---bin
|   |       dbhash.exe
|   |       lemon.exe
|   |       mkkeywordhash.exe
|   |       mksourceid.exe
|   |       sqldiff.exe
|   |       sqlite3.dll
|   |       sqlite3.exe
|   |       sqlite3_analyzer.exe
|   |       sqlite3_checker.exe
|   |       sqltclsh.exe
|   |       src-verify.exe
|   |       tcl86t.dll
|   |       testfixture.exe
|   |       zlib1.dll
|   |       
|   +---demo
|   |       shell.c
|   |       
|   +---inc
|   |       sqlite3.h
|   |       sqlite3ext.h
|   |       
|   \---lib
|           libsqlite3.lib
|           sqlite3.lib
|           
\---output_x64
        sqlite3.dll
        TestSqlite3442Include.exe
        TestSqlite3442Include.pdb
        

如果对sqlite3编程细节有疑问, 就看由shell.c建立的这个工程, 可以单步调试, 各种sqlite3编程用法都有了.

END

相关推荐
静听山水12 小时前
SQLite
数据库·sqlite
6极地诈唬15 小时前
【sqlite】WAL初探
数据库·sqlite
PieroPc15 小时前
用Python Streamlit sqlite3 写一个简单博客
数据库·python·sqlite
码界奇点1 天前
Django视图从基础到高级的全面解析
数据库·django·sqlite·web·python3.11
赋能大师兄1 天前
SQLITE数据库完成数据增删改查
数据库·sqlite
2401_841495641 天前
【数据库开发】个人信息管理的数据库创建以及查询方法(最简单)
数据库·sql·mysql·sqlite·数据库开发·个人数据库·管理个人信息
主宰者2 天前
【C#】.NET Framework 4.8环境下使用Sqlite的问题总结
sqlite·c#·.net
Quz2 天前
QML TableView:基于SQLite实现增删改查
数据库·qt·sqlite
小宁爱Python2 天前
Django Web 开发系列(二):视图进阶、快捷函数与请求响应处理
前端·django·sqlite
6极地诈唬3 天前
【sqlite】xxx.db-journal是什么?
数据库·sqlite