使用openSSL错误编译静态Qt

时间:2012-04-16 06:43:43

标签: c++ qt compiler-errors openssl static-linking

我使用mingw在win32下成功编译了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:\Workplace\OpenSSL\include -L H:\Workplace\OpenSSL

我收到了这些错误:

H:\Workplace\OpenSSL/libssl.a(ssl_lib.o):ssl_lib.c:(.text+0x17be): undefined ref erence to '_time32'(好几次)

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

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

已解决(见下文)

2 个答案:

答案 0 :(得分:2)

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

  • 下载最新的OpenSSL来源并解压缩。

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

  • 安装MSYS。

  • 使用以下内容创建文件../MsysInstallDir/etc/fstab

MyPathToMinGW /mingw(如果使用tdm-gcc则需要)

MyPathToPerl /perl(还需要安装perl)

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

./config

make

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

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

  • 使用config:
  • 在qt sources目录中创建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 MyOpenSSLdir\include -L MyOpenSSLdir

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

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

我认为这可能有助于某人。

答案 1 :(得分:1)

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