Compiling With Clang

Introduction

This short tutorial describes the details of compiling edelib and EDE with the Clang compiler. It is assumed you already have installed a Clang version with the needed libraries.

:!: Note: This tutorial also assumes you have read InstallationHowTo and have prepared the needed libraries and tools.

Compiling FLTK

First we are going to compile FLTK. Clang can use libraries compiled with GCC, so if you can install the latest stable version of FLTK with your distribution's package management system, feel free to do so.

However, if you prefer to compile FLTK with Clang as well, first download FLTK's source code, unpack it and run the following commands in terminal:

$ cd fltk-<version>
$ export CC=clang
$ export CXX=clang++
$ ./configure && make

or in case you would like FLTK to be installed on different place (default is /usr/local, use the prefix) parameter, like:

$ ./configure --prefix=/usr && make

and as superuser, run:

$ make install

Compiling edelib

Normally edelib should compile without problems and compilation commands are pretty much the same as for compiling FLTK (except you are using JAM as build tool). The commands in the right order are:

$ cd edelib-<version>
$ export CC=clang
$ export CXX=clang++
$ ./configure && jam

You can use the prefix parameter to set the desired location. As superuser, running:

$ jam install

will install edelib to the desired location.

Compiling EDE

The commands to build edelib apply here, too. However, if you get strange errors like:

In file included from ActionMenu.cc:14:
In file included from /usr/bin/../lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iostream:39:
In file included from /usr/bin/../lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ostream:39:
In file included from /usr/bin/../lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ios:42:
In file included from /usr/bin/../lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/ios_base.h:40:
/usr/bin/../lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ext/atomicity.h:48:45: error: use of undeclared identifier '__ATOMIC_ACQ_REL'
  { return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
                                            ^
/usr/bin/../lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ext/atomicity.h:52:38: error: use of undeclared identifier '__ATOMIC_ACQ_REL'
  { __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
                                     ^

you are probably running a recent GCC version with a Clang version a bit older. If your distribution does not provide an updated Clang package, you can apply a small hack.

:!: Please note that this hack can change how gcc works, so after you change the given file, recompile EDE and revert those changes!

As superuser, open the file /usr/include/c++/VERSION/PLATFORM-DISTRO/bits/c++config.h, where VERSION is the GCC version (like 4.7.2) and PLATFORM-DISTRO is distribution specific folder, like i686-redhat-linux. Find the line:

#define _GLIBCXX_ATOMIC_BUILTINS 1

and comment it out, like:

// #define _GLIBCXX_ATOMIC_BUILTINS 1

which will disable GCC builtin atomic access functions. Recompile EDE and install it, uncommenting above line afterwards.

Print/export