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

相关推荐
鹏子训1 小时前
AI记忆新思路:用SQLite替代向量数据库,去EMBEDDINGS化,谷歌开源Google Always On Memory Agent
数据库·人工智能·sqlite·embedding
Muyuan19987 小时前
25.Paper RAG Agent 优化记录:上传反馈、计算器安全与 Chunk 参数调整
python·安全·django·sqlite·fastapi
code_pgf6 天前
sqlite数据库cmakelist.txt编译
数据库·sqlite
_F_y6 天前
SQLite3的基础使用
jvm·数据库·sqlite
IntMainJhy6 天前
【flutter for open harmony】第三方库 Flutter 二维码生成的鸿蒙化适配与实战指南
数据库·flutter·华为·sqlite·harmonyos
IntMainJhy6 天前
【flutter for open harmony】第三方库Flutter 国际化多语言的鸿蒙化适配与实战指南
数据库·flutter·华为·sqlite·harmonyos
IntMainJhy6 天前
【flutter for open harmony】Flutter SQLite 本地数据库的鸿蒙化适配与实战指南
数据库·flutter·sqlite
北冥有羽Victoria8 天前
Django Auth组件完整版教程:从原理到项目落地
大数据·服务器·数据库·后端·python·django·sqlite
HackTorjan8 天前
AI图像处理的核心原理:深度学习驱动的视觉特征提取与重构
图像处理·人工智能·深度学习·django·sqlite
somi79 天前
ARM-10-SQLite3 库移植笔记
jvm·笔记·sqlite