Hızlı yanıt: kod örneği
Here is what worked in my environment, on Windows 8.1, overall similar to Seth's instruction, but with fresher tools.
- I installed MinGW 64 into , to be precise I've used STL's distro.
C:/MinGW
- I installed Python 3, just took their latest version.
- I installed CMake 3.0.2
- I forked LLVM and Clang on Github and cloned them to my machine, placing Clang's repo into llvm\tools\clang folder (the structure is described on the official page, they just show examples with svn instead of git).
- I created "build" folder next to "llvm" folder, and inside the "build" folder ran this command: (for some reason CMake couldn't find the "make" automatically)
cmake -G "MinGW Makefiles" -D"CMAKE_MAKE_PROGRAM:FILEPATH=C:/MinGW/bin/make.exe" -DCMAKE_BUILD_TYPE=Release ..\llvm
- Then I ran "make" to actually build. The build took a couple of hours.
- After that in another folder I've created 1.cpp, which executes a lambda expression to print "hi":
#include <iostream>int main() { []{ std::cout << "hi"; }();}
- I've also created a cmd file to compile the cpp. Alternatively you can just set the PATH variable properly via other means. Note that GCC vesrion in your MinGW package may be different. Also Clang has some builtin paths it tries, but they are tied to specific GCC versions, and mine was not among them, so I had to provide the include paths explicitly.
set PATH=<path to the build folder from step 5>/bin;c:/mingw/bin;%PATH%clang++ -std=c++11 1.cpp -o 1.exe -I"C:/MinGW/include"-I"C:/MinGW/include/c++/4.9.1" -I"C:\MinGW\include\c++\4.9.1\x86_64-w64-mingw32" -I"C:\MinGW\x86_64-w64-mingw32\include"
- Running that cmd compiled 1.cpp into 1.exe that printed "hi".
- I've tried building the same llvm+clang sources without MinGW+GCC using the MSVC compiler from VS 2015 CTP. It built Clang successfully, the only difference is that you need to do that from the Developer CMD window, and you'd need to run and then compile the solution in Visual Studio. However, that Clang failed to compile a sample cpp, it complained about "undeclared identifier 'char16_t'" and "__int128 is not supported on this target" within the MinGW standard library headers. If I use clang-cl and MS STL headers it complains about "throw x(y)" specifiers . Maybe I needed to provide some extra keys to the build, but I couldn't get it to work.
cmake -G "Visual Studio 12" ..\llvm