windows 编译32/64位openssl zlib sqlite3

邹缪文
2023-12-01

OPENSSL

1.下载openssl源码 https://www.openssl.org/source/openssl-1.1.1k.tar.gz

2.下载Strawberry Perl工具

3.安装NASM汇编编译器

4.打开Native CMD在openssl源码目录下执行脚本:

perl Configure VC-WIN32 --prefix=c:\build-32

表示编译为VC32位,目标文件在build-32目录下

perl Configure VC-WIN64A  --prefix=    #则表示编译为64位

perl Configure debug-VC-WIN64A --prefix=     #表示debug版

5. nmake all && nmake install

完成

注意:

在执行perl Configure命令时候出现错误:

Configuring OpenSSL version 1.1.1k (0x101010bfL) for VC-WIN32
Using os-specific seed configuration
Can't locate Win32/Console.pm in @INC (you may need to install the Win32::Console module) (@INC contains: C:/Users/Y/Documents/code/openssl-1.1.1k/util/perl C:/Perl64/site/lib C:/Perl64/lib) at C:/Perl64/site/lib/ActivePerl/Config.pm line 400.
Compilation failed in require at C:/Perl64/site/lib/ExtUtils/MakeMaker.pm line 9.
BEGIN failed--compilation aborted at C:/Perl64/site/lib/ExtUtils/MakeMaker.pm line 9.
Compilation failed in require at C:/Perl64/site/lib/IPC/Cmd.pm line 235.

原因是Active Perl缺少组件,卸载后安装Strawberry Perl即可

ZLIB

下载源码 http://zlib.net/

解压后在根目录执行

cmake -B build -A x64 -DCMAKE_INSTALL_PREFIX=C:\code\zlib-1.2.11\install

即可

SQlite3

方法1:直接下载预编译文件,然后执行

lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:x64

或32位

lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:ix86

方法2:

下载源文件,添加CMakeLists.txt

cmake_minimum_required(VERSION 3.19)
set(CMAKE_INSTALL_PREFIX  ..\\install)
project(sqlite3)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_BUILD_TYPE "Release")
aux_source_directory(. sqlite3_src)
add_library(sqlite3 SHARED ${sqlite3_src})
#generate_export_header(tws)
TARGET_LINK_LIBRARIES (sqlite3)  
file(GLOB_RECURSE headers
    *.h
)

install(TARGETS sqlite3 DESTINATION lib)
install(FILES ${headers} DESTINATION include)

再执行

cmake -B build -A x64

按照常规方法编译即可。

测试参考

https://www.cnblogs.com/luego/p/11542420.html

 类似资料: