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

相关推荐
笨鸟先飞,勤能补拙13 小时前
AI 赋能网络安全:技术全景、成熟度评估与实战案例
人工智能·python·安全·web安全·网络安全·sqlite·github
韭菜炒鸡肝天1 天前
Django模型迁移指南:从命令用法到最佳实践
数据库·django·sqlite
2601_960906722 天前
华为MateBook Pro S首发搭载麒麟XE90
华为·postgresql·sqlite·时序数据库·tdengine
天天进步一点点4 天前
QSqlQuery删除sqlite数据库执行drop数据表报错database table is locked unable to fetch row问题
数据库·oracle·sqlite
muddjsv5 天前
SQLite数据库文件机制详解:journal、wal、shm文件作用与备份避坑
数据库·sqlite
光头闪亮亮6 天前
Fyne ( go跨平台GUI )项目实战-项目开发必备基础知识(上)
android·sqlite·go
张人玉6 天前
基于 Vue 3 + ECharts + Express + SQLite 构建的新能源汽车销量数据分析与可视化平台——新能源汽车销量数据分析系统
数据库·vue.js·sqlite·echarts
muddjsv6 天前
SQLite 关系模型详解:表、行、列、主键与外键核心设计思想
数据库·sqlite
muddjsv7 天前
SQLite与MySQL/PostgreSQL本质区别:运行模型、并发、部署、权限全方位对比
mysql·postgresql·sqlite
张人玉8 天前
基于 Vue 3 + ECharts + Express + SQLite 的可视化大屏与业务管理系统——YOLOv8 高精度车辆行人检测与计数系统
数据库·vue.js·yolo·sqlite·echarts·express