c++ - 在 C++ 中使用调试/发布版本 DLL

标签 c++ visual-c++

我正在编写一个可以在 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.

Debug vs Release

也可以使用编译器标志调试您的发布版本。

Debugging Release Builds

  • 堆布局 - 保护字节以防止覆盖
  • 编译 - 删除断言/调试信息
  • 指针支持 - 指针周围的缓冲区以防止段错误
  • 优化 - 内联函数

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

CRT Libraries

关于c++ - 在 C++ 中使用调试/发布版本 DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3901062/

相关文章:

c++ - 为什么 VAO 可以在不绑定(bind)的情况下使用 VBO 数据?

c++ - 在 linux 上使用 c++ 中的键退出无限循环

visual-c++ - 链接 : fatal error LNK1181: cannot open input file

c++ - 如何构建本地唯一标识符名称?

c++ - 如何修复错误 "Variable-sized object may not be initialized "?

c++ - 如何在 Visual Studio 2015 中成功导出 C++ 项目模板?

c++ - 使用 RPC 或其他方式

c++ - 使用 objective-c 框架的 Swift 项目

C++ 新运算符。创建一个新实例

c++ - 使用 Visual Studio 2008 和 SVN 在 C++ 中进行自动版本控制