Skip to content

Commit

Permalink
Update hints on how to link to OpenSSL
Browse files Browse the repository at this point in the history
The traditional way to fix building against a custom OpenSSL is to set the
OPENSSL_LIBS environment variable.

Anyhow, since Qt 5.6 there's a more generic way to configure
linking against external libraries by configuring the <LIB>_INCDIR, <LIB>_LIBDIR,
<LIB>_PREFIX, <LIB>_LIBS, <LIB>_LIBS_DEBUG and <LIB>_LIBS_RELEASE
qmake variables at configure time. Using these have following advantages:

- Can handle different libs for a -debug-and-release build
- Can be used also for other libs than just openssl

So let's try to promote this.

Also update any examples for OpenSSL 1.1.

Change-Id: I24dbccdd87d0fc50bf31c6afe7aa692d4b810fb7
Reviewed-by: Jörg Bornemann <[email protected]>
  • Loading branch information
kkoehne committed Sep 19, 2019
1 parent 52ad1de commit 6bffb8e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/network/configure.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,10 @@
"condition": "features.openssl-linked && libs.openssl.source != 0
&& input.openssl.prefix == '' && input.openssl.libs == '' && input.openssl.libs.debug == ''",
"message": "When linking against OpenSSL, you can override the default
library names through OPENSSL_LIBS.
library names and directories with setting OPENSSL_PREFIX (or OPENSSL_INCDIR, OPENSSL_LIBDIR),
and OPENSSL_LIBS, OPENSSL_LIBS_DEBUG, OPENSSL_LIBS_RELEASE.
For example:
OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl-linked"
./configure -openssl-linked OPENSSL_PREFIX='/opt/ssl' OPENSSL_LIBS='-lssl -lcrypto'"
},
{
"type": "warning",
Expand Down
5 changes: 2 additions & 3 deletions src/network/doc/src/ssl.qdoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@
When building a version of Qt linked against OpenSSL, the build system will
attempt to link with libssl and libcrypt libraries located in the default
location on the developer's system. This location is configurable:
set the \c OPENSSL_LIBS environment variable to contain the linker options
required to link Qt against the installed library. For example, on a Unix/Linux
set the \c OPENSSL_LIBDIR command line argument. For example, on Unix/Linux
system:

\code
OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl-linked
./configure -openssl-linked OPENSSL_LIBDIR=/usr/local/ssl
\endcode

To disable SSL support in a Qt build, configure Qt with the \c{-no-openssl}
Expand Down
4 changes: 2 additions & 2 deletions src/network/ssl/ssl.pri
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ qtConfig(ssl) {
# Add optional SSL libs
# Static linking of OpenSSL with msvc:
# - Binaries http://slproweb.com/products/Win32OpenSSL.html
# - also needs -lUser32 -lAdvapi32 -lGdi32 -lCrypt32
# - also needs -lWs2_32 -lGdi32 -lAdvapi32 -lCrypt32 -lUser32
# - libs in <OPENSSL_DIR>\lib\VC\static
# - configure: -openssl -openssl-linked -I <OPENSSL_DIR>\include -L <OPENSSL_DIR>\lib\VC\static OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32" OPENSSL_LIBS_DEBUG="-lssleay32MDd -llibeay32MDd" OPENSSL_LIBS_RELEASE="-lssleay32MD -llibeay32MD"
# - configure: -openssl-linked -openssl-linked OPENSSL_INCDIR="%OPENSSL_DIR%\include" OPENSSL_LIBDIR="%OPENSSL_DIR%\lib\VC\static" OPENSSL_LIBS="-lWs2_32 -lGdi32 -lAdvapi32 -lCrypt32 -lUser32" OPENSSL_LIBS_DEBUG="-llibssl64MDd -llibcrypto64MDd" OPENSSL_LIBS_RELEASE="-llibssl64MD -llibcrypto64MD"

qtConfig(openssl-linked): \
QMAKE_USE_FOR_PRIVATE += openssl
Expand Down

0 comments on commit 6bffb8e

Please sign in to comment.