Stdlib=libc++ unrecognized

Greetings,

I recently migrated to OSX 10.10 Yosemite. Installed ROOT 5.34.26 via Homebrew. When compiling code that compiled correctly under OSX 10.8 Mountain Lion, ROOT 5.43.00, I get an error of

I use a Makefile for compiling, and the g++ command out of the Makefile for OSX 10.10 is

The g++ command from OSX 10.8 is

If I copy the OSX 10.10 g++ output and paste without the -stdlib=libc++, it compiles correctly.

Is there a way to not have this -stdlib=libc++ in the rootlibs when compiling?

Thanks
MK

Hi,

I think I do not understand what creates the makefile containing the “-stdlib=libc++” switch. Could you clarify what you mean with “Is there a way to not have this -stdlib=libc++ in the rootlibs when compiling?”?

Cheers,
Danilo

I do not understand why the libs -stdlib=libc++ get flagged on with OSX 10.10 but not in OSX 10.8

Compiling in 10.10 will error because of -stdlib=libc++, but the Makefile, on my end, is no different between the systems, nor is the macro. The only difference in compiling this macro with an identical Makefile is the ROOT version and OSX version.

I think what I exactly want to know is how does -stdlib=libc++ get flagged on when I do not flag it in my Makefile.

Hi Michael,

what is then forming the compiler invocation command line with the -stdlib=libc++ flag in your case?

Cheers,
Danilo

I do not know, this is what I am asking.
How do I find out?

Hi,

it’s difficult to know. It depends on your makefile.

D

Here is my MakeFile, but I want to stress the point that this flag is not produced in OSX 10.8 with the same MakeFile.

The error I get is

[quote]michaelkunkel:KINEFITTER$ make
g++ -O -Wall -fPIC -pthread -stdlib=libc++ -m64 -I/usr/local/Cellar/root/5.34.26/include/root -Wno-deprecated -c MergePlot.cc
g++: error: unrecognized command line option '-stdlib=libc++'
make: *** [MergePlot.o] Error 1[/quote]

Maybe it is easier to answer why this error is happening.

[code]# Makefile for the ROOT test programs.

This Makefile shows nicely how to compile and link applications

using the ROOT libraries on all supported platforms.

ARCH = linux

CXX =
ObjSuf = o
SrcSuf = cc
ExeSuf =
DllSuf = so
OutPutOpt = -o
DictSuf = Dict.o

WNO = -Wno-deprecated

ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)

ifeq ($(ARCH),linux)

Linux with gcc 2.7.2.x

CXX = g++
CXXFLAGS = -O -Wall -fPIC
LD = g++
LDFLAGS = -O
SOFLAGS = -shared
endif

ifeq ($(ARCH),linuxrh42)

Linux with gcc 2.7.2.x (RedHat 4.2)

CXX = g++
CXXFLAGS = -O -Wall -fPIC
LD = g++
LDFLAGS = -O
SOFLAGS = -shared
endif

ifeq ($(ARCH),linuxdeb)

Linux with gcc 2.7.2.x

CXX = g++
CXXFLAGS = -O -Wall -fPIC
LD = g++
LDFLAGS = -O
SOFLAGS = -shared
endif

ifeq ($(ARCH),linuxdeb2)

Linux with gcc 2.7.2.x

CXX = g++
CXXFLAGS = -O -Wall -fPIC
LD = g++
LDFLAGS = -O
SOFLAGS = -shared
endif

ifeq ($(ARCH),linuxsuse6)

Linux with gcc 2.7.2.x

CXX = g++
CXXFLAGS = -O -Wall -fPIC
LD = g++
LDFLAGS = -O
SOFLAGS = -shared
endif

ifeq ($(ARCH),linuxegcs)

Linux with egcs (>= RedHat 5.2)

CXX = g++
CXXFLAGS = -O -Wall -fPIC
LD = g++
LDFLAGS = -O
SOFLAGS = -shared
endif

ifeq ($(ARCH),linuxkcc)

Linux with the KAI compiler

CXX = KCC
CXXFLAGS = -fPIC +K0
LD = KCC
LDFLAGS = -O
SOFLAGS =
endif

ifeq ($(ARCH),linuxppcegcs)

MkLinux with egcs/glibc

CXX = g++
CXXFLAGS = -O -Wall -fPIC
LD = g++
LDFLAGS = -O
SOFLAGS = -shared -Wl,-soname,
endif

ifeq ($(ARCH),linuxia64gcc)

Itanium Linux with gcc 2.9x

CXX = g++
CXXFLAGS = -O -Wall -fPIC
LD = g++
LDFLAGS = -O
SOFLAGS = -shared
endif

ifeq ($(ARCH),linuxia64sgi)

Itanium Linux with sgiCC

CXX = sgiCC
CXXFLAGS = -O -Wall -fPIC
LD = gsgiCC
LDFLAGS = -O
SOFLAGS = -shared
endif

ifeq ($(ARCH),linuxalphaegcs)

Alpha Linux with egcs

CXX = g++
CXXFLAGS = -O -Wall -fPIC
LD = g++
LDFLAGS = -O
SOFLAGS = -shared
endif

ifeq ($(ARCH),linuxarm)

ARM Linux with egcs

CXX = g++
CXXFLAGS = -O -Wall -fPIC
LD = g++
LDFLAGS = -O
SOFLAGS = -shared
endif

ifeq ($(CXX),)
$(error $(ARCH) invalid architecture)
endif

TSpectrum = -lSpectrum

CXXFLAGS += $(ROOTCFLAGS)
CXXFLAGS += $(WNO)
LIBS = $(ROOTLIBS) $(SYSLIBS)
#GLIBS = $(ROOTGLIBS) -lrfstream -L/usr/local/lib/ -lshift $(SYSLIBS) -LKFitUtils.o -LKinFit.o
GLIBS = $(ROOTGLIBS) -L/usr/local/lib/ $(SYSLIBS) ccylinder.o intersept.o targcell.o stcounter.o -lgfortran
#GLIBS += $(TSpectrum)

#------------------------------------------------------------------------------

#MAINO = All_Fits_MergePlot_Pi0.$(ObjSuf)
#MAINS = All_Fits_MergePlot_Pi0.$(SrcSuf)
#MAIN = All_Fits_MergePlot_Pi0$(ExeSuf)
#PROGRAMS = $(MAIN)

MAINO = MergePlot.$(ObjSuf)
MAINS = MergePlot.$(SrcSuf)
MAIN = MergePlot$(ExeSuf)
PROGRAMS = $(MAIN)

#MAINO = TestFit.$(ObjSuf)
#MAINS = TestFit.$(SrcSuf)
#MAIN = TestFit$(ExeSuf)
#PROGRAMS = $(MAIN)

#MAINO = mpcal_tdc1.$(ObjSuf)
#MAINS = mpcal_tdc1.$(SrcSuf)
#MAIN = mpcal_tdc1$(ExeSuf)
#PROGRAMS = $(MAIN)

#MAINO = sphe.$(ObjSuf)
#MAINS = sphe.$(SrcSuf)
#MAIN = sphe$(ExeSuf)
#PROGRAMS = $(MAIN)

#MAINO = mpcal_vs.$(ObjSuf)
#MAINS = mpcal_vs.$(SrcSuf)
#MAIN = mpcal_vs$(ExeSuf)
#PROGRAMS = $(MAIN)

#------------------------------------------------------------------------------

.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)

all: $(PROGRAMS)

doc:
root.exe -b -q make_html.C

%.$(ObjSuf):%.$(SrcSuf)
$(CXX) $(CXXFLAGS) -c $<

%Dict.$(SrcSuf):%.h
rootcint -f $@ -c $<

lib%.$(DllSuf): %Dict.$(ObjSuf) %.$(ObjSuf)
$(LD) $(SOFLAGS) $(CXXFLAGS) $^ -o $@

$(MAIN): $(MAINO) $(SLIB)
$(LD) $(CXXFLAGS) $(GLIBS) $^ -o $@

clean:
rm -f $(MAINO)

distclean:
make clean
@rm -f $(SLIB) Dict. *.def

[/code]

Can you tell us the output of $ROOTSYS/bin/root-config --cflags and what version of the gcc compiler you are using?

michaelkunkel:~$ $ROOTSYS/bin/root-config --cflags -pthread -stdlib=libc++ -m64 -I/usr/local/Cellar/root/5.34.26/include/root

michaelkunkel:~$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/4.9.2_1/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/lto-wrapper Target: x86_64-apple-darwin14.0.0 Configured with: ../configure --build=x86_64-apple-darwin14.0.0 --prefix=/usr/local/Cellar/gcc/4.9.2_1 --libdir=/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-4.9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-cloog=/usr/local/opt/cloog --with-isl=/usr/local/opt/isl --with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --with-pkgversion='Homebrew gcc 4.9.2_1' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --enable-multilib Thread model: posix gcc version 4.9.2 (Homebrew gcc 4.9.2_1)

Hi,

this is then more an issue of the packaging Brew did of ROOT if I understand correctly.
I see thre alternatives: modify the makefile expressing the flags explicitly, build your own version of root (it is really straightforward) or use some of the distributed binaries.

Cheers,
Danilo

Greetings,

So I did just what was prescribed a few days before making this post. Even when I built ROOT from source, I received this error. Binary had same effect. Sorry I didn’t mention that earlier.

Greetings,

I have edited my Makefile to reflect all flags used except the -stdlib=libc++ flag. I managed to verify that these are the correct flags from compiling the code on OSX 10.8.

However if I were to use these flags, I get the following error, which does not occur on the OSX 10.8 machine.
This also happens with a source build of ROOT.

michaelkunkel:KINEFITTER$ make g++ -O -Wall -fPIC -pthread -m64 -I/usr/local/opt/root/include/root -Wno-deprecated -c MergePlot.cc g++ -O -Wall -fPIC -pthread -m64 -I/usr/local/opt/root/include/root -Wno-deprecated -L/usr/local/opt/root/lib/root -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lpthread -lm -ldl -L/usr/local/lib/ ccylinder.o intersept.o targcell.o stcounter.o -lgfortran MergePlot.o -o MergePlot Undefined symbols for architecture x86_64: "TObject::SavePrimitive(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from: vtable for TMatrixTBase<double> in MergePlot.o vtable for TMatrixT<double> in MergePlot.o vtable for TVectorT<double> in MergePlot.o "operator>>(std::basic_istream<char, std::char_traits<char> >&, TString&)", referenced from: _main in MergePlot.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status make: *** [MergePlot] Error 1

Hi,

Can you try with v5.34/24?

Thanks,
Philippe.

Greetings,

I have tried to install v5.34/24 through git hub because I cannot find the source otherwise but get errors while building.

I did manage to install v5.34/24 through homebrew and received the following error while compiling

michaelkunkel:KINEFITTER$ make g++ -O -Wall -fPIC -pthread -m64 -I/usr/local/Cellar/root/5.34.24/include/root -Wno-deprecated -c MergePlot.cc g++ -O -Wall -fPIC -pthread -m64 -I/usr/local/Cellar/root/5.34.24/include/root -Wno-deprecated -L/usr/local/Cellar/root/5.34.24/lib/root -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lpthread -lm -ldl -L/usr/local/lib/ ccylinder.o intersept.o targcell.o stcounter.o -lgfortran MergePlot.o -o MergePlot Undefined symbols for architecture x86_64: "TObject::SavePrimitive(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from: vtable for TMatrixTBase<double> in MergePlot.o vtable for TMatrixT<double> in MergePlot.o vtable for TVectorT<double> in MergePlot.o "operator>>(std::basic_istream<char, std::char_traits<char> >&, TString&)", referenced from: _main in MergePlot.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status make: *** [MergePlot] Error 1

Which is the same error received on 5.34/26.

On the machine running OSX10.8, there is v5.34/10 running, but I cannot build this either on OSX 10.10. I will install 5.34/26 on the machine running OSX 10.8 and report back.

hi,

[quote]Undefined symbols for architecture x86_64:[/quote]You should try placing the .o files before the library on the link line (also make sure the .o files have been recompiled against the new header).

[quote]v5.34/26[/quote]This is actually even better :slight_smile:

Cheers,
Philippe.

Greetings,
Using the suggestion

Has not reconciled the compilation problem. No matter where the -o files are loaded an error of

michaelkunkel:KINEFITTER$ make g++ -O -Wall -fPIC -pthread -m64 -I/usr/local/opt/root/include/root -Wno-deprecated -c MergePlot.cc g++ -L/usr/local/opt/root/lib/root -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lpthread -lm -ldl ccylinder.o intersept.o targcell.o stcounter.o -lgfortran -L/usr/local/lib/ MergePlot.o -o MergePlot -O -Wall -fPIC -pthread -m64 -I/usr/local/opt/root/include/root -Wno-deprecated Undefined symbols for architecture x86_64: "TObject::SavePrimitive(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from: vtable for TMatrixTBase<double> in MergePlot.o vtable for TMatrixT<double> in MergePlot.o vtable for TVectorT<double> in MergePlot.o "operator>>(std::basic_istream<char, std::char_traits<char> >&, TString&)", referenced from: _main in MergePlot.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status make: *** [MergePlot] Error 1 michaelkunkel:KINEFITTER$

is produced.
I am still confused on why this will not compile with the current ROOT.

Try to first completely remove any existing “system-provided” ROOT version, everything that’s related to the “Cellar” ROOT, everything that’s related to the “opt” ROOT and then build your ROOT version again from scratch (i.e. [url=https://root-forum.cern.ch/t/missing-canvas/17664/17 from a “fresh” source code[/url]).

I did what was asked and still the same result

michaelkunkel:KINEFITTER$ make g++ -O -Wall -fPIC -pthread -m64 -I/Users/michaelkunkel/root/include -Wno-deprecated -c MergePlot.cc g++ -L/Users/michaelkunkel/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lpthread -lm -ldl ccylinder.o intersept.o targcell.o stcounter.o -lgfortran -L/usr/local/lib/ MergePlot.o -o MergePlot -O -Wall -fPIC -pthread -m64 -I/Users/michaelkunkel/root/include -Wno-deprecated Undefined symbols for architecture x86_64: "TObject::SavePrimitive(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from: vtable for TMatrixTBase<double> in MergePlot.o vtable for TMatrixT<double> in MergePlot.o vtable for TVectorT<double> in MergePlot.o "operator>>(std::basic_istream<char, std::char_traits<char> >&, TString&)", referenced from: _main in MergePlot.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status make: *** [MergePlot] Error 1

I am not sure if the data that root -v gives is the install date, but

[code]michaelkunkel:KINEFITTER$ root -v


  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 5.34/26 20 February 2015 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      http://root.cern.ch            *
    
  •                                     *
    

ROOT 5.34/26 (v5-34-26@v5-34-26, Feb 20 2015, 13:23:25 on macosx64)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0][/code]
gives a date prior to the fresh install I just completed. If this is does reflect the install date, does it mean I did not have a clean install?

The “root -v” output is perfectly fine.
I can see “macosx64” in this output, but in your “MakeFile” (in one of your previous posts), I can see that you enforce “ARCH = linux” which is completely wrong (it should also be “macosx64”, I believe).
Have a look at the newest:
root-config --etcdir/Makefile.arch
Update your “MakeFile” accordingly -> the best idea would be to simply include the “Makefile.arch” in your “MakeFile” -> try the make’s “include” directive -> then each time you change the ROOT version, you will get the “proper” / “newest” / “current” “Makefile.arch” included automatically.

I think I can see another problems in your “MakeFile”.
Change:
GLIBS = $(ROOTGLIBS) -L/usr/local/lib/ $(SYSLIBS) ccylinder.o intersept.o targcell.o stcounter.o -lgfortran
into:
GLIBS = ccylinder.o intersept.o targcell.o stcounter.o $(ROOTGLIBS) -L/usr/local/lib/ $(SYSLIBS) -lgfortran
and:
$(LD) $(CXXFLAGS) $(GLIBS) $^ -o $@
into:
$(LD) $(CXXFLAGS) -o $@ $^ $(GLIBS)
BTW. Try to set (you will get the “proper” value regardless of your current operating system):
ARCH = "$(shell root-config --arch)"
or maybe better do not define it at all as “Makefile.arch” will do it for you automatically (if you include it in your “MakeFile”, of course).