Tips for using clang v3.1 on Windows

Here are the results of me playing around with the new EXPERIMENTAL release v3.1 of clang for Windows using MinGW32:

  1. You don’t need to go through the nightmare of building clang v3.1 yourself - it is right there on the download page, albeit at the very bottom.
  2. Install MinGW32 in the directory C:\MinGW and nowhere else. Otherwise you’ll get all sorts of errors about missing include files and nothing will work at all.
  3. Install all of MinGW32 - MSYS and all of the packages, just to be sure it all works.
  4. Install Clang in a directory without spaces in it (as the clang docs say).
  5. Add both c:\MinGW\bin and clang’s bin directory to your path using the PATH command: path c:\tmp\clang-3.1-win32-mingw32\bin;c:\MinGW\bin;%path%
  6. Be prepared to have to edit your source files a little as MinGW32 is not entirely Microsoft compatible (there’s no GetFileSizeEx() function, for instance).
  7. Remember to use MinGW’s ranlib, not llvm-ranlib, when you create an indexed archive. The latter won’t work and MinGW’s ld will reject the library.

Sample session:

clang++ -c -o a.o a.cpp
clang++ -c -o b.o b.cpp
llvm-ar rcs Test.lib a.o b.o
ranlib Test.lib
clang++ -o c.exe c.cpp Test.lib

Other than that, I have no comments. I managed to build a support library without problems and the module tests ran without any problems. I have not yet had time to play around with LLVM v3.1.

P.S. Thank you guys, it is wonderful that you are now (again) making a binary release for Windows. I think it is the first step in getting rid of the EXPERIMENTAL tag :slight_smile:
P.P.S. And a quick, voiced prayer that we’ll one day see a distro of clang for MinGW64 as well. If I ever figure out how to build it, I’d be happy to build it for release purposes.