-
Notifications
You must be signed in to change notification settings - Fork 1
Building clang (win32)
In this short tutorial, we're going to show you how to build llvm and clang in order to compile Tria. Note: clang is not required to use the Nuria Framework, only to build Tria from source!
- MinGW-based build environment for C/C++. We recommend using the packaged MinGW installed alongside with the official Qt binaries.
- CMake 2.8 or higher. Get your binaries here.
When you're using your current Qt version for the first time with cmake, you'll need to copy the Qt cmake modules so that cmake can find the compiler and Qt itself. Just copy *.cmake
from your Qt directory (C:\Qt\5.3
by default, mind the version!) to [your CMake install]\share\cmake-X.Y\Modules
(substitute X.Y with your CMake version).
Qt, MinGW and cmake all need to be in your PATH
.
You'll need the source code archives for:
- llvm 3.4.x
- clang 3.4.x Both can be grabbed over at llvm.org.
Unpack the llvm source to llvm-src
(anywhere, that name is just how we'll refer to it from now on). Clang (internally called cfe by llvm devs) needs to go to llvm-src\tools\clang
- move and rename the cfe-3.4.x.src
directory in the archive accordingly.
For the next step, you'll be needing a build directory, in which Makefiles will be generated and code compiled. This can be anywhere, but we strongly recommend keeping it outside of the source tree. Consider using llvm-build
in the same top directory as llvm-src
is. We'll assume it is that way.
Get a shell open at llvm-build
. First, you'll need to generate Makefiles using cmake.
cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX="path\to\llvm-install" path\to\llvm-src
What this does is tell cmake to generate Makefiles for use with an MinGW environment (-G "MinGW Makefiles"
) and to plan for an install to path\to\llvm-install
. This is important, since we can't just use a built but not installed clang for building tria, as a lot of libraries and generated headers are scattered around all over build and source directories where they are not found. If you're following the advised directory structure, install to llvm-3.4.x
in the same top-level directory as llvm-src
and llvm-build
are.
You can give additional options here, a full reference can be found in the llvm CMake reference. We recommend limiting which targets to build to x86, just to keep compile time short. The option used for that is -DLLVM_TARGETS_TO_BUILD="X86"
.
Full example (using the recommended directory structure):
cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX="..\llvm-3.4.x" -DLLVM_TARGETS_TO_BUILD="X86" ..\llvm-src
Compile it just like any other software, only remember that make
is called mingw32-make
in MinGW environments.
mingw32-make
If everything compiled successfully, you'll want to install it afterwards.
mingw32-make install
And that's it! You'll need to have [your llvm install]\bin
in your path in order to build Tria.