Compiling Clang on Windows

I followed the instructions http://clang.llvm.org/get_started.html

I compiled the last line of llvm and clang with MSVC 2010. Now I can compile simple programs with Clang, but when I tried to compile this program, I got a lot of errors. Here is the program:

#include <algorithm> int main(){ return 0; } 

And here are some of the errors:

 In file included from hello.cpp:1: In file included from C:\Program Files\Microsoft Visual Studio 10.0\VC\include\algorithm:6: In file included from C:\Program Files\Microsoft Visual Studio 10.0\VC\include\memory:987: In file included from C:\Program Files\Microsoft Visual Studio 10.0\VC\include\intrin.h:24: In file included from H:/LLVM/build/bin/Debug/../lib/clang/3.3/include\immintrin.h:32: In file included from H:/LLVM/build/bin/Debug/../lib/clang/3.3/include\xmmintrin.h:988: H:/LLVM/build/bin/Debug/../lib/clang/3.3/include\emmintrin.h:1384:22: error: expected expression return (__m128)__in; ^ H:/LLVM/build/bin/Debug/../lib/clang/3.3/include\emmintrin.h:1390:23: error: expected expression return (__m128i)__in; ^ H:/LLVM/build/bin/Debug/../lib/clang/3.3/include\emmintrin.h:1396:23: error: expected expression return (__m128d)__in; ^ 

Full output from Clang: http://pastebin.com/qi87K8qr

Clang is trying to use MSVC headers, but it is not working. Maybe I should use lib ++ or libstd ++ instead, but how to do it?

Note I'm not interested in precompiled clang executables

+4
source share
5 answers

Yes, clang just does not support all of Microsoft's extended C ++ syntax and therefore cannot parse Microsoft C ++ headers that use this syntax. Not only that, but Clang also does not have full support for Microsoft C ++ ABI, name changes, etc. I believe that Clang on Windows works well with C.

To use another standard C ++ library, you can force clang to ignore the normal header and library directories with IIRC, -nostdinc++ and -nostdlib++ . You can then specify clang to include and library directories that you want to use (using -isystem or -I or something else). However, I'm not sure if libC ++ or libstdC ++ works under these circumstances, since they probably depend on what does not exist in the Windows C runtime library.

+4
source

Chandler Carruth mentioned in Going Native 2013 that there are alpha builds clang for Windows with Visual Studio integration. Many things are broken, for example, streams (so the good old hello world will not work). However, a lot of effort is being made to make clang work on Windows, so expect it to be pretty good.

+2
source

Errors were in the header supplied with the clan itself. It seems like it cannot handle MMX / SSE types correctly. Try adding -msse -msse2 on the command line.

0
source

I use libstdC ++ and built clang using VS2012Express for the desktop. The cmake line was "Visual Studio 11 Win64" and the main directories. are specified using the -I argument.

0
source

My guess is that you can work if I used mingw headers for Windows.

0
source

All Articles