编译带有 openSSL 错误的静态 Qt

Compiling static Qt with openSSL errors

本文关键字:静态 Qt 错误 openSSL 编译      更新时间:2023-10-16

我成功地在win32下用mingw编译了OpenSSL 1.0.1。现在我正在尝试使用以下配置编译静态Qt 4.8.1:

configure -release -static -qt-zlib -nomake examples -nomake demos -no-qt3support -no-scripttools -no-opengl -no-webkit -no-phonon -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -no-sql-sqlite -openssl-linked OPENSSL_LIBS="-lssl -lcrypto -lgdi32 -luser32" -I H:WorkplaceOpenSSLinclude -L H:WorkplaceOpenSSL

我收到这些错误:

H:WorkplaceOpenSSL/libssl.a(ssl_lib.o):ssl_lib.c:(.text+0x17be): undefined ref erence to '_time32'(多次)

H:WorkplaceOpenSSL/libcrypto.a(o_time.o):o_time.c:(.text+0x362): undefined ref erence to '_gmtime32'

H:WorkplaceOpenSSL/libcrypto.a(mem_dbg.o):mem_dbg.c:(.text+0x4c7): undefined r eference to '_localtime32'

已解决(见下文)

最后我解决了所有问题,这里是使用 TDM-GCC 使用静态 OpenSSL 编译静态 Qt 的完整解决方案。

  • 下载最新OpenSSL的源代码并解压缩它们。

  • 我使用TDM-GCC进行编译,因此请下载并安装它。

  • 安装 MSY。

  • 创建包含以下内容的文件../MsysInstallDir/etc/fstab

MyPathToMinGW /mingw(如果您使用 TDM-GCC,则需要)

MyPathToPerl /perl(还需要安装 perl)

  • 要编译 OpenSSL,请在 OpenSSL 源文件夹(在 MSYS 中)中运行以下命令:

./config

make

  • 下载qt-everywhere(我使用了v.4.8.1)源代码并解压缩它们。

更新:最近我在另一台 windows7 计算机上构建了 4.8.2,并遇到编译错误(在构建我的应用程序时):«找不到 -lQtCore4», «找不到 -lQtGui4»。这是帮助我的解决方案 - 编辑文件"qt-sources-dir/mkspecs/win32-g++/qmake.conf"。设置QMAKE_LFLAGS = -static -static-libgcc

  • 使用配置在Qt源目录中创建conf.bat文件:

configure -release -static -qt-zlib -nomake examples -nomake demos -no-qt3support -no-scripttools -no-opengl -no-webkit -no-phonon -no-style-motif -no-style-cde -no-sql-sqlite -openssl OPENSSL_LIBS="-lssl -lcrypto -lgdi32 -luser32" -I MyOpenSSLdirinclude -L MyOpenSSLdir

  • 运行cmd . 在 Mingw 文件夹中运行mingwvars.bat。 在 QT 源文件夹中运行conf.bat(或将源文件夹添加到 PATH 并从另一个目录运行它,以将安装与源分开)。编译Qt需要几个小时。

  • 添加到项目的 .pro 文件:INCLUDEPATH += OpenSSLdir/include/

我认为这可能会帮助某人。

你确定你需要 -openssl-link 吗?我们总是使用openssl的动态使用来构建Qt。(-openssl)