I've come with problems using shared libraries (.dll in Win 10).
I build a lib called xlib in two different configurations, and try to test use them via CMake in a project called xlibtest.
the work flow is:
Step A. build xlib => xlib.dll + xlib.lib(only symbol) + xlib.pdb[optional]
Step B. build xlibtest and link xlib.lib => xlibtest.exe
If build configuration is different in Step A and Step B, then when I'm running xlibtest.exe, there will be problems. For example, I have a function
//xlib.h
void foo(std::string input);
in xlib, it will crash when I call this function.
//xlibtest.cpp
int main() {
xlib::foo("test"); // in debug mode I found the string pass to foo is wrong
}
I've searched and found some explanation about this problem. It may because of the difference in memory pattern of debug and release configuration. And a suggestion is not mix these two configurations, i.e. use debug lib in debug configuration and release lib in release configuration.
Then here is the problem. I can build two version of my own library. However what can I do for those external libraries?
I've used intel MKL libraries in my project, and linking the same libraries in both debug and release configuration. It seems works fine.
But when I'm using Boost libraries, there may be difference between debug and release version, since we can decide the version we build when install Boost libraries.
P.S. The reason why I don't link with static libraries is that there is error is compile time and requires same configuration (i.e. debug/release).
--Update--
I'm using:
CMake 3.5.2;
Compiler: Intel icl 16.0 update 3 for Intel 64 VS2015 environment;
IDE: VS 2015 Community;
OS: Windows 10, 64 bit.
CPU: Intel i7 4930K
Sorry for not providing these information about the tool chain. I used to thought this is a general problem without relation to the tool chain I use. @Hans Passant
I think answer from @John D may end my confusion. After I learnt there are problem in mixing debug and release configuration, I can't understand why there is no difference in using Intel MKL libs, that's why I post this question. Is it the reason that Intel MKL lib is a C lib that has no std::string in it?