2013-07-17 19:24:07 +02:00
|
|
|
.. index:: clang
|
|
|
|
|
|
|
|
.. highlight:: bash
|
|
|
|
|
2013-08-27 19:17:17 +02:00
|
|
|
.. _install_clang:
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-30 16:15:47 +02:00
|
|
|
Using the clang compiler
|
|
|
|
========================
|
|
|
|
|
|
|
|
**clang/llvm** is one of the very best C++ compilers, with gcc. It is open
|
|
|
|
source on linux and OS X (where it is now the standard compiler provided by
|
|
|
|
Apple).
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-30 16:15:47 +02:00
|
|
|
The **clang** compiler is *highly recommended* for anyone developing in C++ since:
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-30 16:15:47 +02:00
|
|
|
* It is standard compliant (C++11).
|
|
|
|
* It has very nice and useful error messages, much nicer than intel or gcc (even thought gcc is catching up).
|
|
|
|
It really makes little sense to develop with e.g. gcc 4.6 today, especially with a library like TRIQS,
|
|
|
|
which uses a lot of metaprogramming.
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-30 16:15:47 +02:00
|
|
|
Note, however, that for *production* compilations, gcc, especially recent versions, still produces in general
|
2014-07-23 14:14:19 +02:00
|
|
|
a slighly more optimal code for TRIQS applications, even if the differences are small. In fact, a bug in the
|
|
|
|
compiler was recently found and reported.
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2014-07-23 14:14:19 +02:00
|
|
|
It is highly recommended to use the latest stable version on Linux (3.4), and the default compiler on OS X (Mountain lion).
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-27 19:17:17 +02:00
|
|
|
Get and install clang on linux
|
2013-08-30 16:15:47 +02:00
|
|
|
------------------------------
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-30 16:15:47 +02:00
|
|
|
Precompiled versions are available at the `LLVM dowload page <http://llvm.org/releases/download.html>`_.
|
|
|
|
Just untar them and add the directory in your path.
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-30 16:15:47 +02:00
|
|
|
It is also very easy to compile **clang** from source, just follow the
|
2013-07-17 19:24:07 +02:00
|
|
|
`instructions <http://clang.llvm.org/get_started.html#build>`_.
|
|
|
|
|
|
|
|
Usage
|
2013-08-30 16:15:47 +02:00
|
|
|
-----
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-30 16:15:47 +02:00
|
|
|
In order to use clang when building TRIQS::
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-30 16:15:47 +02:00
|
|
|
CXX=clang++ cmake -DCMAKE_INSTALL_PREFIX=path_to_install_directory ../src + other options
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-27 19:17:17 +02:00
|
|
|
.. note::
|
|
|
|
|
2013-08-30 16:15:47 +02:00
|
|
|
On OS X, the options -std=c++11 and -stdlib=libc++ are automatically added by the TRIQS
|
|
|
|
installation script.
|
2013-07-17 19:24:07 +02:00
|
|
|
|