Stdlib=libc++ unrecognized


Switching the order of the GLIBS etc did not change anything. However I was able to solve this issue for the Mac OSX 10.10 and 10.8. It appears that the issue is related back to the -stdlib=libc++ in g++. So using the tip you gave previously

I changed the compiler to clang++, i.e.

[code]ifeq ($(ARCH),macosx64)


CXX = clang++
LD = clang++
SOFLAGS = -shared

with this I was able to revert back to

ROOTCFLAGS := $(shell root-config --cflags) ROOTLIBS := $(shell root-config --libs) ROOTGLIBS := $(shell root-config --glibs)
instead of “cherry=picking” the libs.

Now everything compiles. I am sorry to have wasted time.

I assume you also get “clang++” when you try:
root-config --cxx

You assume correctly. On both machines, OSX 10.8 and OSX 10.10.


To add to this, for the record:

  • The default compiler for building ROOT on MacOS 10.10 is clang. The default standard library is libc++.
  • One cannot use clang with libc++ to build ROOT and then build some more libraries (that are meant to be used with the ROOT libraries) with GCC, as to my knowledge GCC does not support -stdlib=libc++.
  • Instead, either configure ROOT as --with-cc=gcc --with-cxx=g++ --with-ld=g++ plus you might need to also pass --with-gcc-toolchain=directory-where-gcc-is-installed
  • or, much simpler, use the binary compatible clang instead of GCC when building your code.

Any manipulation of the output of root-config --cflags to “make it compile” (especially the removal of -stdlib=libc++ or -std=c++11) will produce incompatible object files that will likely / hopefully cause linker errors.



Is there any consensus how to resolve this issue successfully now? I recently ran into this problem too:

g++: error: unrecognized command line option ‘-stdlib=libc++’

My makefile is like:
ROOTLIBS=root-config --glibs
all: try
$(CXX) -o try $(ROOTINC) $(ROOTLIBS)
It works fine with root 5.43 on earlier version of OS X (now I’m on Yosemite 10.10.3). I tried newer version root 6 and updated Xcode, still has the same problem.

Thanks very much for advice!

CXX:="$(shell root-config --cxx)“
ROOTINC:=”$(shell root-config --cflags)“
ROOTLIBS:=”$(shell root-config --glibs)"
$(CXX) $(ROOTINC) -o try $(ROOTLIBS)