Page 1 of 1

Name debug libraries with "d" postfix on Windows

Posted: Tue Oct 15 2024 11:27 am
by bwm
I build and install CopperSpice on Windows like this:

> cmake --build . --config Release
> cmake --install . --config Release
> cmake --build . --config Debug
> cmake --install . --config Debug

When I then build my own project, cmake should link against the correct library depending on whether my build configuration is release or debug. But it appears that CopperSpice does not add the "d" on debug library names. This results in the Release build being overwritten by the Debug build when the Debug build is installed.

Adding the following line to Windows-specific code in the top-level CMakeLists.txt file results in library names that follow the "d" convention:

SET(CMAKE_DEBUG_POSTFIX d)

Re: Name debug libraries with "d" postfix on Windows

Posted: Tue Oct 15 2024 12:38 pm
by barbara
Are you using MSVC or MinGW on Windows?

Re: Name debug libraries with "d" postfix on Windows

Posted: Tue Oct 15 2024 12:57 pm
by bwm
I use MSVC.

Re: Name debug libraries with "d" postfix on Windows

Posted: Tue Oct 15 2024 9:32 pm
by barbara
Installing Release and Debug builds in the same location is not a supported configuration for MSVC. A suffix on the library names is not sufficient to resolve potential conflicts between the installed files. For example, you need the correct version of UIC, RCC and the exported CMake files.

Instead, you should install the Release and Debug builds to separate directories. Then put both directories on your CMake prefix path and the correct one will be automatically selected when you build your project.

Barbara

Re: Name debug libraries with "d" postfix on Windows

Posted: Wed Oct 16 2024 7:34 am
by bwm
At first this seemed like a better idea, but digging around trying to separate all these libraries turns into a nightmare on a bigger project. I also notice that not only do Microsoft themselves still use this "d" naming convention, all my other dependencies that build with CMake seem to find their libraries correctly when using this naming convention.

So, is there some reason to not follow Microsoft's own naming convention? Even Qt follows this convention, so they can clearly locate uic, rcc, etc during the build process if need be.

Re: Name debug libraries with "d" postfix on Windows

Posted: Fri Oct 18 2024 2:44 pm
by barbara
We are not sure what you mean by "separating all those libraries". There is nothing to separate.

In our CI we have the Release and Debug builds in separate directories with zero issues. The source is in one location and we have multiple build directories and multiple install directories. For the Debug builds we enable all CS debug messaging. This is done by passing a CMake flag.

Barbara