Help on getting C++11 to work

I have installed FreeBSD 9.1, which has the clang 3.1 compiler. As I understand it, if this compiler is used with libc++ and the correct compiler options, then there is 100% support for the new C++ Standard.

1. libc++. This is the new standard that was created as a sub project to the LLVM project. It provides 100% implementation for all C++ 11 features and is 100% complete with no bugs.
If I try to find libc++ by using locate, I get a long listing of directories under:
/usr/src/contrib/libc++/src and
/usr/src/lib/libc++/Makefile.

From this, I assumed that libc++ has not been built, though all the sources are available. So I enter the directory with the makefile and type [CMD="make"][/CMD]. This is the output from that is a warning about object directory not being changed and an error about an unrecognised command line option "-std=c++0x".

What is the position with libc++? Do I have to build it from these sources? If yes, what is the procedure?

2. Assuming libc++ is installed, can you state what entries or changes need to be made to the shell $PATH so that a program using c++11 compiles and links without error?

3. Have you managed to get C++ 11 up and running under FreeBSD 9.1? Do you have 100% of the features available? Or am I attempting to do the impossible here?
 
neilms said:
I have answered my own question, its's ok now
Then please mark your thread as solved. Also, as SNK said, please share your solution with us. Others might be interested in it.

Fonz
 
The solution is that it needs to be built. First:
1. edit /etc/src.conf
-add the following
CC=clang
CXX=clang++
CXXFLAGS+= -stdlib=libc++ -std=c++11
CPP=clang-cpp
WITH_LIBCPLUSPLUS=yes

2. cd /usr/src/lib/libcxxrt && make obj && make depend && make &&
sudo make install
3. cd /usr/src/lib/libc++ && make obj && make depend && make &&

The above install the libc++ headers and libraries in the base system.

After following these steps it is possible - if you want - to rebuild world and link all c++ programs against the new libc++ & libcxxrt. PLease note - I have not gone that far, though people say that there are no problems in doing that. Unless you do this though, it will not be possible to use programs such as curlpp in a c++11 program you write..

In my case, I reached the conclusion that I will keep using the old c++ syntax until compilers & systems are fully updated to support the new standard. I think that whatever claims are made, support for C++ 11 is still experimental.
 
neilms said:
I think that whatever claims are made, support for C++ 11 is still experimental.
Updating compilers to support new standards of C/C++ tends to take quite a while indeed. And by quite a while I do mean years. My advice is to stick with an earlier standard while keeping an eye on how the C++11 support is coming along, so you can make the switch when a sufficient level of support has been reached.

Fonz
 
Back
Top