Qt static with OpenSSL issue
-
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.wrote on 16 Oct 2018, 23:18 last edited by Bernard Lowe@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.wrote on 17 Oct 2018, 06:46 last edited by Cobra91151Hi! 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.wrote on 17 Oct 2018, 14:13 last edited by@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"
wrote on 17 Oct 2018, 15:34 last edited byFailed 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
wrote on 17 Oct 2018, 17:50 last edited byYou 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"
wrote on 17 Oct 2018, 21:48 last edited by@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.
wrote on 9 Mar 2019, 15:06 last edited by@Cobra91151 How did you apply this patch? I'm getting errors
-
@mcpp what exact errors ? What version of OpenSSL ?
-
@Cobra91151 How did you apply this patch? I'm getting errors
wrote on 9 Mar 2019, 22:29 last edited byHi! Please specify what issues with
OpenSSL
you encountered duringQt
static compilation? I will try to help you. -
wrote on 10 Mar 2019, 12:00 last edited byThis post is deleted!