我正在编写一个可以在 Linux (gcc 4.3) 和 Windows (MS VS08 Express) 下编译的 C++ 应用程序。
我的应用程序使用第三方库,
在 Linux 上,它们被编译为共享库,而 在Windows 上,有“Debug”和“Release”两个版本。
我知道 debug 版本为调试提供了额外的支持(就像在 linux gcc 中使用 -ggdb 选项一样,对吧?)
但我发现如果我的应用程序是调试版本,库也必须是调试版本,否则应用程序会崩溃。
为什么会有这样的限制?好像linux的世界没有这个限制
非常感谢!
最佳答案
The Debug configuration of your program is compiled with full symbolic debug information and no optimization. Optimization complicates debugging, because the relationship between source code and generated instructions is more complex.
The Release configuration of your program contains no symbolic debug information and is fully optimized. Debug information can be generated in PDB Files (C++) depending on the compiler options used. Creating PDB files can be very useful if you later need to debug your release version.
也可以使用编译器标志调试您的发布版本。
- 堆布局 - 保护字节以防止覆盖
- 编译 - 删除断言/调试信息
- 指针支持 - 指针周围的缓冲区以防止段错误
- 优化 - 内联函数
Common Problems When Creating Release Builds
详细介绍 Martin Tornwall。 Debug 或 Release 时链接的各种库
LIBCPMT.LIB, Multithreaded, static link, /MT, _MT
LIBCPMTD.LIB, Multithreaded, static link, /MTd, _DEBUG, _MT
关于c++ - 在 C++ 中使用调试/发布版本 DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3901062/