Linking to installed Qt libraries on Linux

I’m having persistent difficulties installing and linking to Qt libraries on Linux.

In previous questions here and here, I asked about how to install Qt libraries along with their namelinks, since the library name searched for by the linker ( was a symlink to rather the file itself.

I had some success with:


…but that didn’t quite work because the only symlink it copied was -> rather than I know that is what I want because if I go to the installation directory and manually type:

ln -s

…then everything works as it should.

So, if I can’t get CMake to generate a link for automatically, it looks like what I need to do is to get my application to link to either or instead of But I can’t see how I can control that.

Please can someone advise?

The .so is the link name (what -lfoo looks for). The .so.5 is the “soname”. This is the ABI-compatibility name that is used when loading the library. The actual implementation lives in the .so.5.12.5 library. This allows the ABI compat link to “float” between multiple installations as needed. You’re always going to have the soname embedded when you make a library (the impl has the soname in it and that is what is copied into the binary as a DT_NEEDED entry. I’d recommend installing* rather than trying to guess what is there.

Yes, that’s it. That’s the solution:

install(CODE "file(COPY ${QT_MAIN_DIR}/lib/  

…and everything works as it ought to. Even though is a symlink rather than the actual file, it installs the actual file and its links correctly, and the application finds its libraries successfully after installation.

Thank you.