I have managed to build clang on Windows 7 using Visual Studio 210 and now I like to use it with the codeblocks IDE. So I copied the clang executables into the mingw bin\\ folde
clang does not support MSVC C++ ABI yet so C++ code cannot be compiled correctly.
Update: As of December 2014, clang does support MSVC except (heh) exceptions. To compile code you will have to do
clang-cl.exe /D_HAS_EXCEPTIONS=0 foo.cpp
If you want to use clang.exe directly:
clang++ -target i686-pc-windows-msvc -D_HAS_EXCEPTIONS=0 foo.cpp -o foo.exe
etc.
For up to date status of MSVC support see http://clang.llvm.org/docs/MSVCCompatibility.html
My CodeBlocks build logs show command lines as
clang++.exe -fno-ms-compatibility -fno-use-cxa-atexit -IC:\mingw\include\c++\4.7.0 -IC:\mingw\include\c++\4.7.0\x86_64-w64-mingw32 -IC:\mingw\include\c++\4.7.0\backward -IC:\mingw\include -c C:\Users\Vipul\Documents\Hello.cpp -o C:\Users\Vipul\Documents\Hello.o
ld.exe -oC:\Users\Vipul\Documents\Hello.exe C:\Users\Vipul\Documents\Hello.o -m i386pep -Bdynamic -Lc:\mingw\lib c:\mingw\lib\crt2.o c:\mingw\lib\crtbegin.o -lstdc++ -lmingw32 -lgcc_s -LC:\Windows\SUA\opt\gcc64\lib\gcc\x86_64-pc-interix6\4.6.0 -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 c:\mingw\lib\crtend.o
and I can run the program. I've built Windows clang with VSExpress. If compilation or link is causing errors on your end, then comparing our command lines might help isolate the issue.
UPDATE
MSYS2 packages are available for clang on 32-bit and 64-bit, and from what limited testing I did it seems to work quite well. The compiler can be used from outside the MSYS2 environment.
On how to install MSYS2, see here. Then just run
pacman -Sy mingw-w64-x86_64-clang
or
pacman -Sy mingw-w64-i686-clang
after updating MSYS2 to install Clang.
The patches used in that package (if you want to build LLVM/Clang yourself) are located here.
old reply follows, slightly out of date
If you want to use Clang on Windows for C++, your only option currently is to use (or build yourself) Clang with/for MinGW(-w64).
Lucky for you, I provide packages:
Unzip both to the same directory and add mingw32-dw2/bin
to PATH
, or point Codeblocks to it. You will be limited to GCC 4.6's libstdc++. Clang 3.2's C++11 language support is fully functional though.
Note that Clang expects GCC style options, so I suggest modifying the Codeblocks GCC build process and replacing g++
with clang++
and gcc
with clang
.