Static build of Qt 5.15.8 with static OpenSSL
-
I have compiled a static build of Qt 5.15.8 from the source on macOS 12 (Xcode 13) with the following option passed to the configure command to enable OpenSSL
../configure .... -static -release -prefix <install_dir> -openssl-linked OPENSSL_PREFIX="$OPENSSL_DIR" OPENSSL_LIBS="$OPENSSL_DIR/lib/libssl.a $OPENSSL_DIR/lib/libcrypto.a" ...
The generated build (the contents of <install_dir> works fine on the machine on which it was built but gives linking errors when moved to a different machine, and setup as a kit in Qt Creator, as it still tries to find the openssl libs in
OPENSSL_DIR
and the expectslibssl.a
andlibcrpyto.a
to be present at$OPENSSL_DIR/lib
which fails as these are build machine paths. It seems the build system hardcodes the value of these variables insidelib/pkgconfig/*.pc
andlib/*.pri
files.What is the correct way to build Qt static libs with openssl static so that it can be moved to a different machine and setup as a kit in Qt Creator?
-
Hi and welcome to devnet,
Out of curiosity, since Qt usually uses the cryptographic framework from Apple, why do you need OpenSSL ?
That said, do you have both OpenSSL's static and dynamic libraires in the same folder ? If so, try to move them in a different folder.
-
@SGaist Thanks!
It's actually a requirement from the client to use openssl on all platforms.
Yes, I do have both static and shared libraries in the same directory. If I remove the shared libs from the directory and keep the
OPENSSL_LIBS="$OPENSSL_DIR/lib/libssl.a $OPENSSL_DIR/lib/libcrypto.a"
in the configure command, I get the same issue.If I remove the
OPENSSL_LIBS
option from the configure command, then it adds-lssl
andlcrypto
and-L<build_machine_path>
in the link command and I get a similar error.Ideally I think, it should not add these libraries/paths implicity with hardcoded paths and throw a missing symbols linking error.
-
@SGaist Following is the output of the otool command.
% otool -L libQt5Network.a Archive : libQt5Network.a libQt5Network.a(qnetworkaccessauthenticationmanager.o): libQt5Network.a(qnetworkaccessmanager.o): libQt5Network.a(qnetworkaccesscache.o): libQt5Network.a(qnetworkaccessbackend.o): libQt5Network.a(qnetworkaccessdebugpipebackend.o): libQt5Network.a(qnetworkaccessfilebackend.o): libQt5Network.a(qnetworkaccesscachebackend.o): libQt5Network.a(qnetworkcookie.o): libQt5Network.a(qnetworkcookiejar.o): libQt5Network.a(qnetworkrequest.o): libQt5Network.a(qnetworkreply.o): libQt5Network.a(qnetworkreplyimpl.o): libQt5Network.a(qnetworkreplydataimpl.o): libQt5Network.a(qnetworkreplyfileimpl.o): libQt5Network.a(qabstractnetworkcache.o): libQt5Network.a(qnetworkfile.o): libQt5Network.a(qhsts.o): libQt5Network.a(qhstspolicy.o): libQt5Network.a(qftp.o): libQt5Network.a(qnetworkaccessftpbackend.o): libQt5Network.a(qnetworkdiskcache.o): libQt5Network.a(qhstsstore.o): libQt5Network.a(bitstreams.o): libQt5Network.a(huffman.o): libQt5Network.a(hpack.o): libQt5Network.a(hpacktable.o): libQt5Network.a(http2frames.o): libQt5Network.a(http2streams.o): libQt5Network.a(http2protocol.o): libQt5Network.a(qabstractprotocolhandler.o): libQt5Network.a(qhttp2protocolhandler.o): libQt5Network.a(qhttpmultipart.o): libQt5Network.a(qhttpnetworkconnection.o): libQt5Network.a(qhttpnetworkconnectionchannel.o): libQt5Network.a(qhttpnetworkheader.o): libQt5Network.a(qhttpnetworkreply.o): libQt5Network.a(qhttpnetworkrequest.o): libQt5Network.a(qhttpprotocolhandler.o): libQt5Network.a(qhttpthreaddelegate.o): libQt5Network.a(qnetworkreplyhttpimpl.o): libQt5Network.a(qhttp2configuration.o): libQt5Network.a(qspdyprotocolhandler.o): libQt5Network.a(qnetworksession.o): libQt5Network.a(qnetworkconfigmanager.o): libQt5Network.a(qnetworkconfiguration.o): libQt5Network.a(qnetworkconfigmanager_p.o): libQt5Network.a(qbearerengine.o): libQt5Network.a(qbearerplugin.o): libQt5Network.a(qsharednetworksession.o): libQt5Network.a(qauthenticator.o): libQt5Network.a(qhostaddress.o): libQt5Network.a(qhostinfo.o): libQt5Network.a(qnetworkdatagram.o): libQt5Network.a(qnetworkinterface.o): libQt5Network.a(qnetworkproxy.o): libQt5Network.a(qurlinfo.o): libQt5Network.a(qdnslookup.o): libQt5Network.a(qdnslookup_unix.o): libQt5Network.a(qhostinfo_unix.o): libQt5Network.a(qnetworkinterface_unix.o): libQt5Network.a(qnetworkproxy_mac.o): libQt5Network.a(qabstractsocketengine.o): libQt5Network.a(qabstractsocket.o): libQt5Network.a(qtcpsocket.o): libQt5Network.a(qudpsocket.o): libQt5Network.a(qtcpserver.o): libQt5Network.a(qsocks5socketengine.o): libQt5Network.a(qhttpsocketengine.o): libQt5Network.a(qnativesocketengine.o): libQt5Network.a(qnativesocketengine_unix.o): libQt5Network.a(qlocalsocket.o): libQt5Network.a(qlocalserver.o): libQt5Network.a(qlocalsocket_unix.o): libQt5Network.a(qlocalserver_unix.o): libQt5Network.a(qasn1element.o): libQt5Network.a(qssl.o): libQt5Network.a(qsslcertificate.o): libQt5Network.a(qsslcertificateextension.o): libQt5Network.a(qsslconfiguration.o): libQt5Network.a(qsslcipher.o): libQt5Network.a(qssldiffiehellmanparameters.o): libQt5Network.a(qsslellipticcurve.o): libQt5Network.a(qsslkey_p.o): libQt5Network.a(qsslerror.o): libQt5Network.a(qsslsocket.o): libQt5Network.a(qsslpresharedkeyauthenticator.o): libQt5Network.a(qocspresponse.o): libQt5Network.a(qdtls.o): libQt5Network.a(qsslsocket_openssl_symbols.o): libQt5Network.a(qssldiffiehellmanparameters_openssl.o): libQt5Network.a(qsslcertificate_openssl.o): libQt5Network.a(qsslellipticcurve_openssl.o): libQt5Network.a(qsslkey_openssl.o): libQt5Network.a(qsslsocket_openssl.o): libQt5Network.a(qsslcontext_openssl.o): libQt5Network.a(qdtls_openssl.o): libQt5Network.a(qsslsocket_mac_shared.o): libQt5Network.a(qpassworddigestor.o): libQt5Network.a(qnetconmonitor_darwin.o): libQt5Network.a(moc_qnetworkaccesscache_p.o): libQt5Network.a(moc_qnetworkaccessbackend_p.o): libQt5Network.a(moc_qnetworkaccessdebugpipebackend_p.o): libQt5Network.a(moc_qnetworkaccessfilebackend_p.o): libQt5Network.a(moc_qnetworkcookiejar.o): libQt5Network.a(moc_qnetworkreply.o): libQt5Network.a(moc_qabstractnetworkcache.o): libQt5Network.a(moc_qnetworkfile_p.o): libQt5Network.a(moc_qnetworkaccessftpbackend_p.o): libQt5Network.a(moc_qnetworkdiskcache.o): libQt5Network.a(moc_qhttp2protocolhandler_p.o): libQt5Network.a(moc_qhttpmultipart.o): libQt5Network.a(moc_qhttpnetworkreply_p.o): libQt5Network.a(moc_qhttpthreaddelegate_p.o): libQt5Network.a(moc_qnetworkreplyhttpimpl_p.o): libQt5Network.a(moc_qspdyprotocolhandler_p.o): libQt5Network.a(moc_qnetworkconfigmanager_p.o): libQt5Network.a(moc_qnetworksession_p.o): libQt5Network.a(moc_qbearerplugin_p.o): libQt5Network.a(moc_qhostinfo_p.o): libQt5Network.a(moc_qnetworkproxy.o): libQt5Network.a(moc_qnetconmonitor_p.o): libQt5Network.a(moc_qdnslookup_p.o): libQt5Network.a(moc_qabstractsocketengine_p.o): libQt5Network.a(moc_qtcpsocket.o): libQt5Network.a(moc_qudpsocket.o): libQt5Network.a(moc_qsocks5socketengine_p.o): libQt5Network.a(moc_qhttpsocketengine_p.o): libQt5Network.a(moc_qnativesocketengine_p.o): libQt5Network.a(moc_qsslerror.o): libQt5Network.a(moc_qdtls.o):
-
@SGaist I am getting the following errors
clang: error: no such file or directory: '/Users/qtbuilder/Downloads/openssl-1.1.1t/install_dir/lib/libssl.a' clang: error: no such file or directory: '/Users/qtbuilder/Downloads/openssl-1.1.1t/install_dir/lib/libcrypto.a'
Note that this path is present only on the machine where qt was built from source (static with static openssl). If I copy the install directory (generated by
make install
) to another machine, then I get these errors on building samples that require openssl (eg securesocketclient). Somehow the paths passed inOPENSSL_LIBS
configure variable get hardcoded. -
@quutee sounds like it's a bug. You should check the bug report system to see if there's something related.