I got a mysterious 'RuntimeLibrary' link error today.
We have a main executable project, and a few static library projects. The executable project links against to the static libraries. All the projects' runtime library setting were set to Multi-Thread (/MT). Everything goes well until we added a third party pre-compiled static link library.
When the library was added, we encountered many unresolved symbol error. I know many of you can't wait to tell me just change the runtime library setting. Yes that's what we did. As the library's document says it's compiled in /MD, We changed all the projects' setting to Multi-Thread DLL (/MD). However, we still encountered many unresolved symbol errors in VC++ runtime library, plus a mysterious error:
a.obj: error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MT_DynamicRelease' in b.obj
From the error message, we know that there must be something used /MT instead of /MD. But as I mentioned above, we changed every projects' setting to the same. We searched the internet to find out why, and found a post says they meet a problem very close to ours (). However, that's not our story.
After hours of digging into the SVN log, we found something interesting. At a very early stage of adding another project which produces a static link library, he / she changed EVERY cpp files' compile settings to use /MT, and changing the project's setting DOES NOT affact the source files' settings! Ay caramba! What the HELL was Microsoft thinking! Why would any one change a single cpp's runtime setting in ONE project?!
We changed all the source files' setting back to 'inherit from parent', and it worked like a charm.