简体   繁体   English

C ++以发布模式进行构建,库处于调试模式

[英]c++ build with release mode with library in debug mode

我想知道是否在发布模式下构建项目并将链接在调试模式下构建的库链接到该库,库是否会优化?

No. If your library is compiled in debug mode, the code is unoptimized. 否。如果您的库是在调试模式下编译的,则代码未经过优化。 If you link this library to your release library, the library will still remain unoptimized (the linker cannot recompile the library!) Keep in mind, that once a library is compiled, the binary is fixed and doesn't change any more. 如果将此库链接到发行库,则该库仍将处于未优化状态(链接器无法重新编译该库!)请记住,一旦编译了库,二进制文件便已修复,并且不会再更改。

If you are on Windows, your debug library will be also linked against the debug runtime, while the release library will be linked against the release runtime, making it unlikely to work at all due to symbol conflicts. 如果您使用的是Windows,则调试库还将与调试运行时链接,而发布库将与发布运行时链接,由于符号冲突,使其根本无法工作。

如果该库是在调试模式下构建的,则将不会对其进行优化!

The library code was already done at it's compile time, so No, it won't have optimized code. 库代码已经在编译时完成了,所以不,它不会具有优化的代码。

Debug/Release code optimizations are done at compile time. 调试/发布代码优化在编译时完成。 Since the library is already compiled, then no, it will not have "release" optimizations. 由于该库已经编译过,因此不会,它不会进行“发行”优化。

As a side note , release optimizations are usually up to developer (he needs to put his verbose and other auxiliary functions under the #ifdef DEBUG preprocessor switch). 附带说明一下,发布优化通常取决于开发人员(他需要将其详细功能和其他辅助功能放在#ifdef DEBUG预处理程序开关下)。

So the library might already be quite optimized (depending on the library implementation), it just has debug symbols enabled . 因此,该库可能已经非常优化(取决于库的实现),只是启用了调试符号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM