OpenSSL 3 with QT 6 on Ubuntu

OpenSSL 3 with QT 6 on Ubuntu

Since version 6.5, Qt is now build with OpenSSL v3. Here’s is how you can compile and build your project by using OpenSSL 3 on Ubuntu.

Downloading

Run the Qt Maintenance tool and install the OpenSSL Toolkit:

By default, the OpenSSL sources should be installed in ~/Qt/Tools/OpenSSLv3/src

Compiling

Once installed, open a terminal window and follow theses steps to compile OpenSSL 3:

cd ~/Qt/Tools/OpenSSLv3/src
./Configure
make
sudo make install

At this point, OpenSSL3 should be compiled and installed. Let’s update links and cache:

sudo ldconfig

Let’s create this file to update the system-wide configuration for OpenSSL:

sudo tee /etc/profile.d/openssl.sh<<EOF
export PATH=/usr/local/bin:\$PATH
export LD_LIBRARY_PATH=/usr/local/lib64:\$LD_LIBRARY_PATH
EOF

Load the updated environment:

source /etc/profile.d/openssl.sh

Verify the installed version:

openssl version

The output should display the version 3.x of OpenSSL.

It is recommended to reboot at this point:

sudo reboot

Linking

To use OpenSSL v3 in your Qt application, you can link statically to it like this in CMakeLists.txt:

set(OPENSSL /home/user/Qt/Tools/OpenSSLv3/src)
target_link_libraries(MyProject ${OPENSSL}/libssl.so ${OPENSSL}/libcrypto.so)

That’s it. You should now be able to use OpenSSL 3 in your Qt software.