My project links a lot of static libraries. All of them previously links well, but now I added mysql c api library and now I gets errors like that:
mysqlclient.lib(client_authentication.obj) : error LNK2038: mismatch detected for "_ITERATOR_DEBUG_LEVEL": value "0" doesn't match value "2" in mysql_database_connection.obj
mysqlclient.lib(client_authentication.obj) : error LNK2038: mismatch detected for "RuntimeLibrary": value "MT_StaticRelease" doesn't match value "MTd_StaticDebug" in mysql_database_connection.obj
But only if I builds project with MTd option of MSVC runtime library (I using this runtime library option for development). Other static libraries links well. I can fix errors through changing MTd to MT, but I want to use MTd. Why other static libraries links ok? Compile options was same (libraries compiled by myself), MT option for all libraries, but only mysql c api can't be linked with my project MTd option.
Why?
Thanks in advance!
The error indicates a conflict between the CRT libraries used in your project (/MTd
multithread static debug) and the ones used by the statically linked library (/MT
multithread static release). This is an error condition because one module (EXE or DLL) can only have/use one copy of the CRT.
From the /MD, /MT, /LD (Use Run-Time Library) notes:
All modules passed to a given invocation of the linker must have been compiled with the same run-time library compiler option
To fix the error, either build the project with /MT
(release configuration), or rebuild the static library with /MTd
(debug configuration) and link to that debug library, instead.
Libraries that do not use the MSVC runtimes are not affected, and can be used with either debug or release builds without worries.