Reputation: 863
I would like to know if building a project in Release mode and linking a library build in Debug mode to it, the library will be optimized or not?
Upvotes: 1
Views: 905
Reputation: 4763
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).
So the library might already be quite optimized (depending on the library implementation), it just has debug symbols enabled .
Upvotes: 1
Reputation: 19404
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.
Upvotes: 3