How to Building Static Qt with Static Openssl

Is there any way to building static Qt with static OpenSSL?

Is there any way to building static Qt with static OpenSSL?

Sure, you need to use the following option when configuring Qt:

-openssl-linked

The reason is that QtNetwork uses the QLibrary class by default for dynamically opening the library to get the necessary symbols.

This is the option to tell Qt not to do so, and respect the the normal linkage rules.

That being said, it is not recommended to use static linkage for openssl if security updates need to be available for the end user without your involvement. Consider that for a moment what happens if you are gone, not working on this project anymore, etc.

Also, this setup is not tested frequently, so you may actually encounter some issues that should be fixed upstream, but this is solution design for the use case in question.

Disclaimer: since SO is about programming, I am ignoring the licensing consequences for static linking againt Qt, so I would just like to quickly remind that you that be aware of the proper usage not to get into legal troubles.

Compiling static Qt with openSSL errors

Finally I solved all problems, here is full solution to compile static Qt with static OpenSSL using TDM-GCC.

  • Download sources of latest OpenSSL and unpack them.

  • I used TDM-GCC to compile, so download and install it.

  • Install MSYS.

  • Create file ../MsysInstallDir/etc/fstab with the following content:

MyPathToMinGW /mingw (REQUIRED if you use tdm-gcc)

MyPathToPerl /perl (perl is also required to be installed)

  • to compile OpenSSL run the following commands in OpenSSL sources folder (in MSYS):

./config

make

  • download qt-everywhere (I used v.4.8.1) sources and unpack them.

UPDATE: Recently I built 4.8.2 on another windows7 computer and got compiling error (while building my app): «cannot find -lQtCore4», «cannot find -lQtGui4». Here is the solution that helped me - edit file "qt-sources-dir/mkspecs/win32-g++/qmake.conf". Set QMAKE_LFLAGS = -static -static-libgcc

  • create conf.bat file in qt sources dir with config:

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

  • run cmd. run mingwvars.bat in mingw folder. run conf.bat in qt sources folder (or add sources folder to the PATH and run it from another directory, to separate install from sources). It will take a few hours to compile Qt.

  • add to project's .pro file: INCLUDEPATH += OpenSSLdir/include/

I think it may help somebody.



Related Topics



Leave a reply



Submit