Building LLVM with static linking on Windows

I’m trying to build LLVM 3.5.1 on Windows, almost successfully; the remaining stumbling block is getting static linking for release builds. The problem is that the .vcxproj is interpreted by msbuild to compile with the /MD option instead of /MT, as detailed in:

https://stackoverflow.com/questions/28262372/getting-msbuild-to-use-mt-staticrelease

Haven’t got any answers on that question, and discussion in:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/1a6dd13c-9f5c-430b-88ba-518bfcca00b1/how-to-set-the-runtime-library-to-mt-on-command-line-with-msbuild?forum=vcgeneral

suggests msbuild isn’t even capable of such.

What’s the best way to get a static release build?

You need to cmake with

-DLLVM_USE_CRT_DEBUG=MTd

-DLLVM_USE_CRT_RELEASE=MT

for static linking with Debug and Release configurations reprectively.

Yaron

That works, thanks!