Search code examples
visual-studiomsbuildllvmstatic-linking

Getting msbuild to use MT_StaticRelease


How do you get msbuild to use MT_StaticRelease?

The package I'm trying to build is LLVM 3.5.1 using Visual Studio 12 64-bit on Windows 7, and the closest I've come to what seems like it should be the right command line is

msbuild /p:Configuration=Release /p:RuntimeLibrary=MT_StaticRelease ALL_BUILD.vcxproj

but attempting to compile a test program against the LLVM libraries gets error messages like

LLVMSupport.lib(CommandLine.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main-0b0089.obj

which suggests msbuild is still using /MD instead of /MT and eyeballing the build process seems to confirm that. Is there some command line option I'm missing?


Solution

  • You need to configure this in LLVM's CMake configuration:

     LLVM_USE_CRT_DEBUG=MTd
     LLVM_USE_CRT_RELEASE=MT