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

相关推荐
mariokkm9 小时前
Django一分钟:在Django中怎么存储树形结构的数据,DRF校验递归嵌套模型的替代方案
数据库·django·sqlite
Rookie也要加油12 小时前
01_SQLite
数据库·sqlite
mariokkm2 天前
Django一分钟:使用prefetch_related避免陷入大量的查询中导致严重的性能问题
数据库·django·sqlite
一只小松许️2 天前
SQLite数据库介绍
数据库·c++·sqlite
niu_sama3 天前
SQLite3
jvm·oracle·sqlite
橘子海全栈攻城狮3 天前
【源码+文档+调试讲解】交通信息管理系统
运维·开发语言·数据库·python·sqlite
mariokkm4 天前
Django一分钟:DRF ViewSet烹饪指南,创建好用的视图集
python·django·sqlite
暮毅4 天前
二、创建drf纯净项目
数据库·sqlite
牵牛老人5 天前
Qt开发技巧(九)去掉切换按钮,直接传样式文件,字体设置,QImage超强,巧用Qt的全局对象,信号槽断连,低量数据就用sqlite
开发语言·qt·sqlite
我命由我123455 天前
7-1.Android SQLite 之 SQLiteDatabase 简单编码模板(SQLiteDatabase 使用、SQL 语句编写)
android·数据库·sql·sqlite·安卓·database·android-studio