Question

It's quite easy to get clang++ to use GCC's libstdc++ (-stdlib=stdc++), but how can I do the converse? On OS X Mavericks, the c++ system library is libc++, which means that basically libstdc++ cannot be used (if you mix with other c++ libraries such as boost that have been compiled with libc++). So, roughly, that means G++ is not usable... Unless I can ask it to use libc++ rather than libstdc++.

Thanks.

The script I use (EDIT)

I'm using the following script, g++-libc++, to run g++ on top of libc++, on Mac OS X with MacPorts (hence the -mp names.

#! /bin/sh

clangxx=clang++-mp-3.5
gxx=g++-mp-4.9

libcxx_includes=$($clangxx -print-search-dirs |
                  perl -ne 's{^libraries: =(.*)}{$1/../../../} && print')

exec $gxx -std=c++11 \
   -isystem ${libcxx_includes}/include/c++/v1 \
   -nostdinc++ -nodefaultlibs \
   -lc -lc++ -lc++abi -lgcc_s.10.5 \
   -Wl,-no_compact_unwind \
   "$@"
Was it helpful?

Solution

Something like:

g++ -std=c++0x -nostdinc++ -nodefaultlibs -lc -isystem <path_to>/include/c++/v1 -lc++ -lc++abi -lgcc_s.10.5

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top