Name debug libraries with "d" postfix on Windows

Report any problems with CopperSpice
Post Reply
bwm
Posts: 6
Joined: Mon May 27 2024 12:52 pm

Name debug libraries with "d" postfix on Windows

Post 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)
barbara
Posts: 475
Joined: Sat Apr 04 2015 2:32 am
Contact:

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

Post by barbara »

Are you using MSVC or MinGW on Windows?
bwm
Posts: 6
Joined: Mon May 27 2024 12:52 pm

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

Post by bwm »

I use MSVC.
barbara
Posts: 475
Joined: Sat Apr 04 2015 2:32 am
Contact:

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

Post 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
bwm
Posts: 6
Joined: Mon May 27 2024 12:52 pm

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

Post 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.
barbara
Posts: 475
Joined: Sat Apr 04 2015 2:32 am
Contact:

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

Post 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
Post Reply