Linking against Openssl 1.1.2-dev Libs
-
Hi there,
i want to use Openssl 1.1.2-dev inside my QT-Project. Therefore i added the following lines to the Project File:
win32: LIBS += -L$$PWD/../openssl/openssl/ -llibcrypto win32: LIBS += -L$$PWD/../openssl/openssl/ -llibssl INCLUDEPATH += $$PWD/../openssl/openssl/include DEPENDPATH += $$PWD/../openssl/openssl/include
The Folders should be correct.
So inside the main.cpp i included one openssl header:
#include "openssl/x509.h"
and added some example code - just for testing without real data:
d2i_X509(nullptr, nullptr, 0);
Then i run the code (Debug Version) and i got the error:
main.cpp:14: Error: undefined reference to `d2i_X509'
So what is the problem? Is my linking correct? Or did is miss something? Don't know where is the problem because i did it this way with an older version of Openssl (1.0.1) - the only difference are the lib names in the old version: libeay32 lssleay32.
-
@Opa114 said in Linking against Openssl 1.1.2-dev Libs:
-llibssl.dll
Afaik you can't link directly against a dll but need an import lib. There must be a 'libssl.a' somehwere around which you have to link to with '-lssl'. The same goes for libcrypto.dll
-
@Christian-Ehrlicher
sorry my mistake - i copied some old stuff. i removed the *.dll ending.
Inside the folder: L$$PWD/../openssl/openssl/ there is a licrypto.a and libcrypto.dll.a, same for the ssl lib. -
Hi @Opa114,
Just to add to @Christian-Ehrlicher,
There must be a 'libssl.a' somehwere around
Or, depending on compiler, its named libssl.lib.
So the linker call should look like this:
win32: LIBS += -L$$PWD/../openssl/openssl/ -lcrypto -lssl
Also, make sure OpenSSL was build with the same compiler you are using for your Qt project.
Regards
-
@aha_1980 said in Linking against Openssl 1.1.2-dev Libs:
Hi @Opa114,
Just to add to @Christian-Ehrlicher,
There must be a 'libssl.a' somehwere around
Or, depending on compiler, its named libssl.lib.
So the linker call should look like this:
win32: LIBS += -L$$PWD/../openssl/openssl/ -lcrypto -lssl
Also, make sure OpenSSL was build with the same compiler you are using for your Qt project.
Regards
when i try it with -lcrypto and -lssl then i got this error:
skipping incompatible C:\Users\Matth\Desktop\openssl\openssl/libcrypto.a when searching for -lcrypto skipping incompatible C:\Users\Matth\Desktop\openssl\openssl/libcrypto.dll.a when searching for -lcrypto cannot find -lcrypto
same for the ssl library.
-
@Opa114 said in Linking against Openssl 1.1.2-dev Libs:
skipping incompatible
That is already a hint :)
Again:
- which compiler is used for OpenSSL and for your project?
- are both 32bit resp. 64bit?
Regards
-
@aha_1980
For OpenSSL i used MinGW (this way and built it under Ubuntu: ./Configure mingw --cross-compile-prefix=i686-w64-mingw32- - prefix=/mnt/c/Users/Matth/Desktop/openssl/BUILD)And for my Project i used MinGW 64 (qmake: qmake.exe test.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug" and Make: mingw32-make.exe -j4 in C:\Users\Matth\Desktop\build-test-Desktop_Qt_5_12_0_MinGW_64_bit-Debug)
But both should be 32bit builds i think.
-
@Opa114 said in Linking against Openssl 1.1.2-dev Libs:
i686-w64-mingw32
Are you sure this means 32 bit?
Edit: at least MinGW 64 is not 32bit ;)
Edit2: can you build OpenSSL on Windows with the MinGW64 compiler? Should avoid all possible incompatibilities :)
-
@Opa114
instead of building openssl under windows i run it again under ubuntu and did a cross compile but now with minGW 64bit which creates a 64-bit dll. With these it works. but should a 64bit application able to use 32bit dlls? Or i am wrong? -
@Opa114 said in Linking against Openssl 1.1.2-dev Libs:
But should a 64bit application able to use 32bit dlls? Or i am wrong?
Sorry, but yes you are. You cannot mix these.
Regards
-
@aha_1980 said in Linking against Openssl 1.1.2-dev Libs:
@Opa114 said in Linking against Openssl 1.1.2-dev Libs:
But should a 64bit application able to use 32bit dlls? Or i am wrong?
Sorry, but yes you are. You cannot mix these.
Regards
okay thanks for clarification. So it was my mistake because i thought i can mix it. I know the other way would not work.