How to compile Cilk code on a Linux machine :

General idea :
1. Download the good version of the GCC sources 4.7.0 on the GIT of GCC : branch "cilkplus"
2. Download all the libs that are needed and put them into the directory "checkouted" from the branch
3. configure, make, make install

Note : in the detailed procedure all the texts that are in white font on a dark background are able to be "copy/pasted" directly !
Note2 : in the detailed procedure all the texts in italic is not important and is just here as a precision

Detailed procedure :

1. create a new directory : $HOME/cilkplus-install
1a. create a new directory : $HOME/gcc-4.7
1b. Checkout this GCC branch : http://http://gcc.gnu.org/svn/gcc/branches/cilkplus/ 
(svn co http://http://gcc.gnu.org/svn/gcc/branches/cilkplus/ )
The archive will be named in a bad way...name it just test.tgz and extract it here : $HOME/gcc-4.7

You can notice that you download a snapshot and that you do not checkout the branch "cilkplus" of GCC. This is related to the fact that the "cilkplus" branch is experimental and is not always stable and the guys from Intel are working on it very often to keep it working. BUT at the time when I am writing this little tutorial the branch does not compile ! So you have to download this snapshot !
For your information the original branch is here : http://gcc.gnu.org/svn/gcc/branches/cilkplus/
If you want you can checkout it with the command : svn co http://gcc.gnu.org/svn/gcc/branches/cilkplus/
But I don't guarantee anything if you do that :)

2. Download the libraries needed for GCC to be compiled !
GMP from this link : http://gmplib.org/
MPFR from this link : http://www.mpfr.org/mpfr-current/#download
GPC from this link : http://www.gnu-pascal.de/alpha/

You have to download the source, and put each of this into a directory in the gcc-4.7 directory, in order to have this :
$HOME/gcc-4.7/gmp/
$HOME/gcc-4.7/mpfr/
$HOME/gcc-4.7/gpc/
Then install (sudo apt-get install) :
* Flex
* gcc-multilib

Reference for the pre-requisites to install GCC : http://gcc.gnu.org/install/prerequisites.html
3. Create a new directory $HOME/b-gcc

4. Open a terminal go to $HOME/b-gcc

5. One you are in b-gcc directory : type this command : $HOME/gcc-4.7/configure prefix=$HOME/cilkplus-install enable-languages="c,c++" 

6. If everything is ok, go to step "7"
6a. if not try typing this : $HOME/gcc-4.7/configure prefix=$HOME/cilkplus-install enable-languages="c,c++" --disable-multilib 
and then go to step "7"

7. (still in the b-gcc directory) type "make" and wait. (It will take at least 1 or 2 hours depending on the machine...On my Quad Core it has taken more than 1 hour (!!))
Don't worry about the warnings during the "make" process...


8. If there are no errors at the end of the "make" process then you can type "make install"
You will find the executable in this directory : $HOME/cilkplus-install/bin 

9. Here is a sample code that compiles after the installation, you can copy it, and put it into a file called "test.cpp" :
#include <cilk/cilk.h>
#include <stdio.h>

int fib(int n)
{
    int x, y;

    if (n < 2)
       return n;

    x = cilk_spawn fib(n-1);
    y = fib(n-2);
    cilk_sync;
    return x+y;
}

int main(int argc, char **argv)
{
    int n = 30;
    printf("fib(%d): %d\n", n, fib(n));
    return 0;
}

10. how to compile test.cpp ?
Type these commands in a terminal (you can work now into your favorite directory where you have put "test.cpp")
export LD_LIBRARY_PATH=$HOME/cilkplus-install/lib
export LIBRARY_PATH=$HOME/cilkplus-install/lib 
$HOME/cilkplus-install/bin/g++ -ldl -lcilkrts test.cpp
And you are DONE, you can execute the file "a.out" by typing : ./a.out

10a. Generic command to compile
$HOME/cilkplus-install/bin/gcc -ldl -lcilkrts <OTHER_FLAGS> <SOURCE_FILES>
$HOME/cilkplus-install/bin/g++ -ldl -lcilkrts <OTHER_FLAGS> <SOURCE_FILES>