Building a C++0x version of gcc

I am really excited about the upcoming C++ standard, nicknamed C++0x. It would be great to have a compiler that supports some of the proposed features, instead of just reading about them. So I set out to build the C++0x version of gcc.

Here is a quick description that worked for me (OS X 10.4):

$ svn -q checkout svn:// gcc0x
$ cd gcc0x
$ ./configure

This gave me the following error message:

configure: error: Building GCC requires GMP 4.1+ and MPFR 2.2.1+.

which I fixed by porting mpfr and gmp.

$ sudo port install mpfr gmp gmp-cxx-wrappers

and then I could configure, make and install like this (compilation takes about an hour):

$ ./configure --enable-languages=c++ --with-gmp=/opt/local --with-mpfr=/opt/local
$ make
$ sudo make install
$ /usr/local/bin/g++ --version
g++ (GCC) 4.3.0 20070628 (experimental)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO

Now I can write C++ programs and play around with new language features, such as static assertions, variadic templates, delegating constructors and decltype. I can also use some of the new library stuff, such as <regex>, <tuple>, <type_traits> and more… Cool!

Note, for some reason I get a warning during linking. It says:

/usr/bin/ld: warning can't open dynamic library: /libgcc_s.1.dylib ...

The code links and run so you can perhaps just ignore the warning, but here is a workaround that silence the linker:

g++ -Wl,-dylib_file,/libgcc_s.1.dylib:/usr/local/lib/libgcc_s.1.dylib foo.cpp

Have fun!

Comments are closed.