Building LLVM with VisualStudio 2017

Hello everyone,

so there is something that really bothers me. In the past I build LLVM and Clang via the source code and Visual Studio 2015.

In my project I used then the freshly new build Clang and the LLVM.

But now, since I compiled with Visual Studio 2017 this is not possible anymore. I’m able to compile both, the LLVM and clang, but when I then use clang as the compiler and the LLVM in my project, I get undefined references to: “__std_reverse_trivially_swappable_4”

And other functions like this.

I also tried, when CMake has generated the Solution file, to change the compiler to LLVM. Clang is executed then, but still – the same error will occur in my project or different projects when they are compiled with Clang.

What am I doing wrong? It prevents me from continuing my project…

Kind greetings


something i expirenced when i added the IRParser lib to the Fibonacci example (using cmakelists.txt) - in a clean first build

after the change i was unable to build the project (with masses of errors)

rebuilding on the console with cmake build "repaired" the sln

But building the LLVM and Clang is no problem at all.
The problem occurs when I use the generated LLVM lib files in a project, which I compile with Clang.

Hey Stella,

(Gaier is my last name :0)

I do the same steps as you do! The resulting Clang compiler is indeed working. I have problems with the LLVM library.

When I build the LLVM7 I use the libraries of it in a different project - a JIT client.
When I compile this solution with Visual Studio 2017 and the MSVC compiler, then I get no problems.

But, when I switch to the Clang-cl compiler in Visual Studio 2017, then I get suddenly these undefined references.
The strange thing is, that this also happens when I compile the LLVM with a preinstalled Clang.

Kind greetings

Hey Bjorn,

Were you able to figure this out or is it still broken for you?

Our scenario is a little bit different, but I have a theory as to what may be going wrong. What linker are you using when you compile your project with clang-cl? I am wondering whether the version of the linker and/or the libraries that you are using is too old in comparison to the one used for the clang compilation.


Hi Björn, hi Stella

Sorry, didn't notice this thread earlier. In January I had a similar
issue with LLVM 3.8 on Window 10. I couldn't solve it, but my workaround
at least unblocked development: I simply defined an external C function
with that exact name myself :slight_smile: Something like:

external "C" void __std_reverse_trivially_swappable_8() {}

With that the linker was happy. I put an explicit breakpoint instruction
in there and it was never actually hit. In case you want to investigate
further, there are more people with this problem here:


Hello Stella and Stefan,

I actually worked around the problem by installing the LLVM plug-in for Visual Studio - now I was able to successfully link the LLVM libraries in projects where I used clang as the compiler.
As a linker I always used the MSVC linker - for building LLVM/Clang and the said project.

Kind greetings