How to link debug version of Qt?

I have read in the Qt docs that:

The Qt library contains hundreds of internal checks that will print warning messages when a programming error is detected. We therefore recommend that you use a debug version of Qt when developing Qt-based software.

So I want to link a “debug version of Qt” when compiling PDF4QT.

It uses CMake with vcpkg as package manager when configuring its build.

How can I do that?

I have tried appending -DCMAKE_BUILD_TYPE=Debug to the config line, but after using ldd on the generated binary I found out that the Release version of the Qt library is still used.

Here are the exact commands I issued:

cmake --build build_debug --config Debug -j12

Then after compiling if I do for example ldd ./build_debug/Pdf4QtViewerLite/Pdf4QtViewerLite I get: => /usr/lib/

So it’s still linked to the release build.

I have tried running the config step with --trace-expand. Here are the logs.

Looking at the logs, you seem to use your system installed Qt, and not one provided by vcpkg.

/usr/lib/cmake/Qt6Core/Qt6CoreTargets.cmake(117):  include(/usr/lib/cmake/Qt6Core/Qt6CoreTargets-relwithdebinfo.cmake )

I don’t know much about the project, but looking at its vcpkg.json file, it does not list qt as a dependency.

I suspect you’ll either have to manually add it there, or convince vcpkg somehow to install qt and use that version.

That was it. Thanks!