NP Rooski  Z
NP Rooski Z

Reputation: 3657

Force system QT libraries to use openssl libraries shipped with the application

My application = libssl.so (1.0.2f) + libcrypto.so (1.0.2f) + my_app_exe

On Debian 9, QT version is 5.7 and openssl is 1.0.2l

my_app_exe returns 1.0.2l for QSslSocket::sslLibraryVersionString(), which means its using system openssl version.

Can I force QT libraries to somehow use openssl shipped along with my application?

I've tried setting library path using QCoreApplication::addLibraryPath(const QString &path), but QT library still picks up system openssl version.

Constraints:

my_app_exe already uses RPATH which points to the current directory where shipped openssl resides.

Upvotes: 3

Views: 1530

Answers (1)

NP Rooski  Z
NP Rooski Z

Reputation: 3657

On Debian 9 I was able to get the correct SSL and Crypto libraries to load if I preload (load them as the first thing in the main()) using QLibrary calls. This is exactly what QT libraries are doing loadOpenSsl()

    int main()
    {
        QLibrary libcrypto, libssl;
        libcrypto.setFileNameAndVersion(QLatin1String("crypto"), QLatin1String(SHLIB_VERSION_NUMBER));    
        libssl.setFileNameAndVersion(QLatin1String("ssl"), QLatin1String(SHLIB_VERSION_NUMBER));

        ...<snipped>...
        return 0;
     }

Remember, I also have RPATH set on the application

$ objdump -x my_app_exe | grep -i RPATH
  RPATH                $ORIGIN/lib

crypto libraries are stored in ./my_app_exe/lib/lib{ssl,crypto}.so

BTW, setting LD_LIBRARY_PATH didn't work for me.

Upvotes: 4

Related Questions