Qt static with OpenSSL issue
-
Hi! So there are no actual patch files, only embedded code in the post? Thanks.
-
The post contains the patch. Copy the content in a file and then you can apply it.
-
Ok. I will try the patch and reply later. Thanks.
-
Hi! I have tried it but I get issue:
I think there is a syntax error in the file. I will check it.
-
Did you do the build from a clean state ?
In anywise, you should use out of source builds, so if something goes wrong, you can juste nuke the folder and start again.
-
Did you do the build from a clean state ?
In anywise, you should use out of source builds, so if something goes wrong, you can juste nuke the folder and start again.
Yes, I have a zip copy and delete old src dir and extract the new every time the build fails. So it is a clean state. I validated
json
using the https://jsonlint.com service and it displays errors:So it contains syntax errors. It's messy to write it all (patch) to config/pri files, better would be replace the files. I will try to fix these errors.
-
Now it fails with the error:
Info: creating super cache file D:\QtBuild\Src\.qmake.super D:/QtBuild/Src/qtbase/mkspecs/features/qt_configure.prf:1941: Error parsing JSON at 411:41: unterminated array Project ERROR: Invalid or non-existent file D:/QtBuild/Src/qtbase/src/network/configure.json.
I will disable the
xmlpatterns
and try again. -
It fails with another issue:
I use
Win32 OpenSSL v1.0.2p
. I will try different version:Win32OpenSSL-1_0_2L
. -
The same issue still exists with
Win32OpenSSL-1_0_2L
:I use
Qt 5.9.6
. Has anyone buildQt 5.9.6
statically withOpenSSL
successfully? I think the problem is withQt
, not theOpenSSL
libs. Thanks. -
I was wrong. I came across this issue: https://bugreports.qt.io/browse/QTBUG-58024
The problem was with theOpenSSL libs
. I have downloadedOpenSSL v1.0.2l (stable)
forVS 2017
from the website: https://www.npcglib.org/~stathis/blog/precompiled-openssl/Extracted it, and added to the include/libs path in my batch file. Now it compiles without errors:
SET /P qtBuildType=Qt build type (shared/static): SET /P qtBuildMySqlIncludePath=MySql include path: SET /P qtBuildMySqlLibPath=MySql lib path: SET /P qtBuildOpenSSLIncludePath=OpenSSL include path: SET /P qtBuildOpenSSLLibPath=OpenSSL lib path: SET /P qtBuildPath=Enter Qt build path: configure.bat -debug-and-release -%qtBuildType% -opensource -nomake tools -nomake examples -no-ltcg -sql-mysql -I "%qtBuildMySqlIncludePath%" -L "%qtBuildMySqlLibPath%" -ssl -openssl -openssl-linked -I "%qtBuildOpenSSLIncludePath%" -L "%qtBuildOpenSSLLibPath%" OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32 -lCrypt32" OPENSSL_LIBS_DEBUG="-lssleay32MTd -llibeay32MTd" OPENSSL_LIBS_RELEASE="-lssleay32MT -llibeay32MT" -prefix "%qtBuildPath%"
-
I was wrong. I came across this issue: https://bugreports.qt.io/browse/QTBUG-58024
The problem was with theOpenSSL libs
. I have downloadedOpenSSL v1.0.2l (stable)
forVS 2017
from the website: https://www.npcglib.org/~stathis/blog/precompiled-openssl/Extracted it, and added to the include/libs path in my batch file. Now it compiles without errors:
SET /P qtBuildType=Qt build type (shared/static): SET /P qtBuildMySqlIncludePath=MySql include path: SET /P qtBuildMySqlLibPath=MySql lib path: SET /P qtBuildOpenSSLIncludePath=OpenSSL include path: SET /P qtBuildOpenSSLLibPath=OpenSSL lib path: SET /P qtBuildPath=Enter Qt build path: configure.bat -debug-and-release -%qtBuildType% -opensource -nomake tools -nomake examples -no-ltcg -sql-mysql -I "%qtBuildMySqlIncludePath%" -L "%qtBuildMySqlLibPath%" -ssl -openssl -openssl-linked -I "%qtBuildOpenSSLIncludePath%" -L "%qtBuildOpenSSLLibPath%" OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32 -lCrypt32" OPENSSL_LIBS_DEBUG="-lssleay32MTd -llibeay32MTd" OPENSSL_LIBS_RELEASE="-lssleay32MT -llibeay32MT" -prefix "%qtBuildPath%"
@Cobra91151 I followed these steps which lead to a successful compilation. Now, however, my application crashes immediately after launch. Have you seen anything like this? Thanks
-
@Cobra91151 I followed these steps which lead to a successful compilation. Now, however, my application crashes immediately after launch. Have you seen anything like this? Thanks
Hi! What is your compiler? Try to attach the debugger to the application and check again. By the way, check my
Qt
static withMySQL
issue here: https://forum.qt.io/topic/94378/qt-static-with-mysql-issue/33 to get more information aboutQt
static compilation. -
Hi! What is your compiler? Try to attach the debugger to the application and check again. By the way, check my
Qt
static withMySQL
issue here: https://forum.qt.io/topic/94378/qt-static-with-mysql-issue/33 to get more information aboutQt
static compilation.@Cobra91151 Hello! Thanks for your comprehensive response. My compiler is VS 2017 (linked with OpenSSL v1.0.2l). I had a debugger attached (cdb.exe) through qtcreator which would detatch the debugger before the main entry point. I am on openssl 'l' so your post could be very relevant here so I'll explore after trying one more thing:
One major oops that I had just realized was that I left in MD instead of MT after setting -static-runtime in configure so I am trying with MT now. -
@Cobra91151 Hello! Thanks for your comprehensive response. My compiler is VS 2017 (linked with OpenSSL v1.0.2l). I had a debugger attached (cdb.exe) through qtcreator which would detatch the debugger before the main entry point. I am on openssl 'l' so your post could be very relevant here so I'll explore after trying one more thing:
One major oops that I had just realized was that I left in MD instead of MT after setting -static-runtime in configure so I am trying with MT now.Hi! Try compiling
Qt
withSSL
/MT
libs and reply. By the way, you can check if it work withVisual Studio
before compilingQt
. By creating simple console project:Code:
#include <iostream> #include <openssl/bio.h> #include <openssl/ssl.h> #include <openssl/err.h> using namespace std; int main() { cout << "Hello World!" << endl; SSL_load_error_strings(); ERR_load_BIO_strings(); OpenSSL_add_all_algorithms(); system("Pause"); return 0; }
Don't forget to add all the
OpenSSL
includes/libs toVS 2017
and changeRuntime library
toMulti-threaded (/MT)
(as Release) inCode Generation
section. -
Hi! Try compiling
Qt
withSSL
/MT
libs and reply. By the way, you can check if it work withVisual Studio
before compilingQt
. By creating simple console project:Code:
#include <iostream> #include <openssl/bio.h> #include <openssl/ssl.h> #include <openssl/err.h> using namespace std; int main() { cout << "Hello World!" << endl; SSL_load_error_strings(); ERR_load_BIO_strings(); OpenSSL_add_all_algorithms(); system("Pause"); return 0; }
Don't forget to add all the
OpenSSL
includes/libs toVS 2017
and changeRuntime library
toMulti-threaded (/MT)
(as Release) inCode Generation
section.@Cobra91151
Your spike solution worked perfectly, it was also quite revealing because after succeeding using https://www.npcglib.org/~stathis/blog/precompiled-openssl/ MT libs with static runtime in Visual Studio, I attempted to use the MD libs and the linker attempted to look for a ssleay32MD DLL as if it was a windows system library which was not expected behavior for me.My build did not fare as well because I was attempting to use https://slproweb.com/products/Win32OpenSSL.html libraries. I will now try npcg lib with MT and static runtime set. Crossing my fingers.
Here was my configure command on that last failed build using slproweb libs
configure -prefix C:\Qt\5.11.2_openssl -mp -debug-and-release -opengl desktop -opensource -static -static-runtime -opensource -confirm-license -no-icu -no-sql-sqlite -no-qml-debug -nomake examples -nomake tests -skip qtactiveqt -skip qtserialport -skip qtquickcontrols -skip qtsensors -skip qtlocation -skip qtscript -platform win32-msvc -openssl-linked -I C:\OpenSSL-Win64\include -L C:\OpenSSL-Win64\lib\VC\static OPENSSL_LIBS_DEBUG="libeay32MTd.lib ssleay32MTd.lib" OPENSSL_LIBS_RELEASE="libeay32MT.lib ssleay32MT.lib"
-
@Cobra91151
Your spike solution worked perfectly, it was also quite revealing because after succeeding using https://www.npcglib.org/~stathis/blog/precompiled-openssl/ MT libs with static runtime in Visual Studio, I attempted to use the MD libs and the linker attempted to look for a ssleay32MD DLL as if it was a windows system library which was not expected behavior for me.My build did not fare as well because I was attempting to use https://slproweb.com/products/Win32OpenSSL.html libraries. I will now try npcg lib with MT and static runtime set. Crossing my fingers.
Here was my configure command on that last failed build using slproweb libs
configure -prefix C:\Qt\5.11.2_openssl -mp -debug-and-release -opengl desktop -opensource -static -static-runtime -opensource -confirm-license -no-icu -no-sql-sqlite -no-qml-debug -nomake examples -nomake tests -skip qtactiveqt -skip qtserialport -skip qtquickcontrols -skip qtsensors -skip qtlocation -skip qtscript -platform win32-msvc -openssl-linked -I C:\OpenSSL-Win64\include -L C:\OpenSSL-Win64\lib\VC\static OPENSSL_LIBS_DEBUG="libeay32MTd.lib ssleay32MTd.lib" OPENSSL_LIBS_RELEASE="libeay32MT.lib ssleay32MT.lib"
Failed on unresolved external errors akin to below:
libeay32MT.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp_CreateCompatibleBitmap referenced in function readscreen
It looks like i need to link in GDI as well according to this Stack Overflow post
-
Failed on unresolved external errors akin to below:
libeay32MT.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp_CreateCompatibleBitmap referenced in function readscreen
It looks like i need to link in GDI as well according to this Stack Overflow post
You need to specify additional libs to configure. I have the batch file for
Qt
compilation. For example, you need:Debug:
OPENSSL_LIBS="-llibeay32MTd -lssleay32MTd -lUser32 -lAdvapi32 -lGdi32 -lCrypt32"
Release:
OPENSSL_LIBS="-llibeay32MT -lssleay32MT -lUser32 -lAdvapi32 -lGdi32 -lCrypt32"
-
You need to specify additional libs to configure. I have the batch file for
Qt
compilation. For example, you need:Debug:
OPENSSL_LIBS="-llibeay32MTd -lssleay32MTd -lUser32 -lAdvapi32 -lGdi32 -lCrypt32"
Release:
OPENSSL_LIBS="-llibeay32MT -lssleay32MT -lUser32 -lAdvapi32 -lGdi32 -lCrypt32"
@Cobra91151 Wish that I saw your note earlier. I got it to work using this configure:
configure -prefix C:\Qt\5.11.2_openssl -mp -debug-and-release -opengl desktop -opensource -static -static-runtime -opensource -confirm-license -no-icu -no-sql-sqlite -no-qml-debug -nomake examples -nomake tests -skip qtactiveqt -skip qtserialport -skip qtquickcontrols -skip qtsensors -skip qtlocation -skip qtscript -platform win32-msvc -openssl-linked -I C:\Development\openssl-1.0.2l-vs2017\include64 -L C:\Development\openssl-1.0.2l-vs2017\lib64 OPENSSL_LIBS_DEBUG="libeay32MTd.lib ssleay32MTd.lib gdi32.lib User32.lib" OPENSSL_LIBS_RELEASE="libeay32MT.lib ssleay32MT.lib gdi32.lib User32.lib"
-
Ok. I will try the patch and reply later. Thanks.
@Cobra91151 How did you apply this patch? I'm getting errors