Comment by delta_p_delta_x
1 year ago
There's a bit of a conflation here; partially my fault. Allow me to clarify...
To generate debug symbols for a given binary (whether executable or library) on Windows and MSVC's cl.exe (and Clang on Windows), compile with `/DEBUG`[1] and one of `/Z7`, `/Zi`, or `/ZI`[2]. This is equivalent to `-g` on Linux gcc/clang. In particular, `/Z7` generates separate `.pdb` files, which contain debug symbols for the binary in question.
The options that the parent commenter and I were discussing, i.e. `/MD`, `/MDd`, /MT`, and `/MTd`[3] have to do with the C and C++ runtime link configuration. These correspond to multithreaded dynamic, multithreaded dynamic debug, multithreaded static, and multithreaded static debug respectively. Therefore, the small `d` refers to debug versions of the C and C++ runtimes. The differences between the debug and release versions of the C and C++ runtimes are listed in the following links[4][5][6][7][8]. The last link in particular demonstrates the debug CRT's functionality.
Conventionally on Windows, debug binaries are linked to the debug versions of the C and C++ runtimes; ergo the requirement that 'Release and Debug binaries on Windows cannot be combined'. This convention is respected by all maintainers who release binary libraries on Windows.
There is no equivalent on Unix-likes: it'd be like having 'debug' versions of libc.so.6/libstdc++.so/libc++.so/libpthread.so with different ABIs. If you wanted to change between release/debug here, you would have to at least re-link (if not re-compile) everything. Imagine having `-cstdlib=libc-debug` and `stdlib=libc++-debug` options.
Both sets of options (debug symbol options and C runtime link options) are orthogonal, and may be freely combined. Hence, it is perfectly possible to link the debug versions of the C and C++ runtimes to a 'release' executable, although it would be pretty weird. For instance, `/O2 /LTCG /arch:AVX2 /MTd`. Equivalent imaginary GNU-style command: `-O3 -flto=thin -march=x86-64-v3 -cstdlib=libc-debug stdlib=libc++-debug -static`. You can see what I mean, I hope.
[1]: https://learn.microsoft.com/en-gb/cpp/build/reference/debug-...
[2]: https://learn.microsoft.com/en-gb/cpp/build/reference/z7-zi-...
[3]: https://learn.microsoft.com/en-gb/cpp/build/reference/md-mt-...
[4]: https://learn.microsoft.com/en-gb/cpp/c-runtime-library/c-ru...
[5]: https://learn.microsoft.com/en-gb/cpp/c-runtime-library/crt-...
[6]: https://learn.microsoft.com/en-gb/cpp/c-runtime-library/debu...
[7]: https://learn.microsoft.com/en-gb/cpp/c-runtime-library/run-...
[8]: https://learn.microsoft.com/en-gb/cpp/c-runtime-library/crt-...
> ...having 'debug' versions of libc.so.6/libstdc++.so/libc++.so/libpthread.so with different ABIs
would be actually cool