Windows7下编译SQLCipher

目的:完成sqlite的加密,使用sqlcipher4.0.1,将windows,android统一

 

参照该链接https://github.com/sqlitebrowser/sqlitebrowser/wiki/Win64-setup-%E2%80%94-Compiling-SQLCipher,也就是照着做吧

萌新照搬过来,记录操作步骤

环境:

Visual Studio 2017专业版

vs_buildtools.exe

OpenSSL v1.1.1a   https://slproweb.com/products/Win32OpenSSL.html    安装路径C:\ dev \ OpenSSL-Win64

ActiveTcl 8.5(不知道有没有用,反正装了一个)

sqlcipher4.0.1源码  https://github.com/sqlcipher/sqlcipher/releases

 

准备就绪,开始修改值sqlcipher-4.0.1 \ Makefile.msc

参照链接说的灰常清晰,注意不要输错

对照看吧,可能版本不同,该文件显示不一致

下边对照该版本是第269行

# This is the name to use for the SQLite dynamic link library (DLL).
#
!IFNDEF SQLITE3DLL
!IF $(FOR_WIN10)!=0
SQLITE3DLL = winsqlite3.dll
!ELSE
SQLITE3DLL = sqlcipher.dll  ### sqlite3.dll 改为  sqlcipher.dll
!ENDIF
!ENDIF

# This is the name to use for the SQLite import library (LIB).
#
!IFNDEF SQLITE3LIB
!IF $(FOR_WIN10)!=0
SQLITE3LIB = winsqlite3.lib
!ELSE
SQLITE3LIB = sqlcipher.lib  ### sqlite3.lib改为  sqlcipher.lib
!ENDIF
!ENDIF

# This is the name to use for the SQLite shell executable (EXE).
#
!IFNDEF SQLITE3EXE
!IF $(FOR_WIN10)!=0
SQLITE3EXE = winsqlite3shell.exe
!ELSE
SQLITE3EXE = sqlcipher.exe  ### sqlite3shell.exe  改为  sqlcipher.exe  
!ENDIF
!ENDIF

# This is the argument used to set the program database (PDB) file for the
# SQLite shell executable (EXE).
#
!IFNDEF SQLITE3EXEPDB
!IF $(FOR_WIN10)!=0
SQLITE3EXEPDB =
!ELSE
SQLITE3EXEPDB = /pdb:sqlciphersh.pdb   ### /pdb:sqlite3sh.pdb  改为  /pdb:sqlciphersh.pdb   
!ENDIF
!ENDIF

第968行添加下面代码,该路径“C:\ dev \ OpenSSL-Win64”是你安装的路径

# Flags controlling use of the in memory btree implementation
#
# SQLITE_TEMP_STORE is 0 to force temporary tables to be in a file, 1 to
# default to file, 2 to default to memory, and 3 to force temporary
# tables to always be in memory.
#
TCC = $(TCC) -DSQLITE_TEMP_STORE=2
RCC = $(RCC) -DSQLITE_TEMP_STORE=2

# Add -DSQLITE_HAS_CODEC to TCC and RCC
TCC = $(TCC) -DSQLITE_HAS_CODEC
RCC = $(RCC) -DSQLITE_HAS_CODEC

# Add OpenSSL include path to TCC and RCC 
TCC = $(TCC) -IC:\dev\OpenSSL-Win64\include
RCC = $(RCC) -IC:\dev\OpenSSL-Win64\include

第1183行添加如下代码,其中.lib文件是在“C:\ dev \ OpenSSL-Win64 \ lib”下所有尾缀为.lib文件

# Add OpenSSL library path andd library filenames
LTLIBPATHS = $(LTLIBPATHS) /LIBPATH:C:\dev\OpenSSL-Win64\lib /LIBPATH:C:\dev\OpenSSL-Win64\lib\VC
LTLIBS = $(LTLIBS) capi.lib dasync.lib libapps.lib libcrypto.lib libcrypto_static.lib libssl.lib libssl_static.lib libtestutil.lib openssl.lib ossltest.lib padlock.lib uitest.lib 

所有程序-VS2017-Visual Studio Tools-随便打开个黑窗口,切换到sqlcipher-4.0.1 \目录下,执行下边命令

nmake /f Makefile.msc

结果如下:
.lib padlock.lib uitest.lib
  正在创建库 sqlcipher.lib 和对象 sqlcipher.exp
        cl -nologo -W4 -DINCLUDE_MSVC_H=1   -DSQLITE_OS_WIN=1 -I. -I. -I.\src -f
p:precise -MT -DNDEBUG -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_C
RT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -DSQLITE_THREADSAFE=1 -DSQLIT
E_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_TEMP_STORE=2 -DSQLITE_HAS_CODEC -IC:\dev\Open
SSL-Win64\include  -DSQLITE_MAX_TRIGGER_DEPTH=100  -DSQLITE_ENABLE_FTS3=1 -DSQLI
TE_ENABLE_RTREE=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENA
BLE_STMTVTAB=1 -DSQLITE_ENABLE_DBPAGE_VTAB=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQL
ITE_INTROSPECTION_PRAGMAS=1 -DSQLITE_ENABLE_DESERIALIZE=1 -DSQLITE_ENABLE_COLUMN
_METADATA=1   -O2 -Zi -Fesqlcipher.exe  -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_E
XPLAIN_COMMENTS=1 -DSQLITE_ENABLE_OFFSET_SQL_FUNC=1 -DSQLITE_ENABLE_DESERIALIZE=
1 -DHAVE_READLINE=0 shell.c sqlite3.c  /link /pdb:sqlciphersh.pdb /DEBUG   /NOLO
GO /MACHINE:x64   /LIBPATH:C:\dev\OpenSSL-Win64\lib /LIBPATH:C:\dev\OpenSSL-Win6
4\lib\VC sqlite3res.lo   capi.lib dasync.lib libapps.lib libcrypto.lib libcrypto
_static.lib libssl.lib libssl_static.lib libtestutil.lib openssl.lib ossltest.li
b padlock.lib uitest.lib
shell.c
sqlite3.c
sqlite3.c(77253): warning C4389: “!=”: 有符号/无符号不匹配
正在生成代码...
LINK : 没有找到 sqlcipher.exe 或上一个增量链接没有生成它;正在执行完全链接

生成了sqlcipher.exe

打开sqlcipher.exe时,显示libcrypto-1_1-x64.dll缺失

该在链接https://blog.csdn.net/qq_37887537/article/details/79455814中找到了答案

libcrypto-1_1-x64.dll文件下载,他的链接如果失效了可以试试

链接:https://pan.baidu.com/s/12uh3c6G-vRRBwYYWUJZ35g 
提取码:70ja 

下载的libcrypto-1_1-x64.dll文件放置C:\ Windows \ System32目录下,即可

 

你可能感兴趣的:(sqlcipher)