Error compiling program on Snow Leopard for 64 bit

Dear ROOTers

On my MacBook Pro I have just installed Snow Leopard and the new Xcode 3.2.2 from Apple.

First I have compiled root_v5.24/00 for 32 bit and tried to compile my program but got a link error. Since my Makefile
does “include Makefile.arch” from the root/test directory I downloaded the newest Makefile.arch from svn, which finally
allowed me to compile my program.

Then I have compiled root_v5.24/00 for 64 bit and tried to compile my program again, but this time I got this link error:

ld: invalid option to -undefined [ warning | error | suppress | dynamic_lookup ]
collect2: ld returned 1 exit status

Do you know the reason for getting this error?
Could there be a problem in the newest version of Makefile.arch?

BTW, in my “.bashrc” file I have:

export MACOSX_DEPLOYMENT_TARGET=10.6
#export MACOSX_DEPLOYMENT_TARGET=10.5
export ROOTSYS=/Volumes/CoreData/ROOT/root
export PATH=$ROOTSYS/bin:$PATH
export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$ROOTSYS/lib:$DYLD_LIBRARY_PATH

Is this still correct for Snow Leopard?
Could this cause the problem?

Best regards
Christian

Hi,

what option did you specify to -undefined as ld complains about? The opt for 10.6 should be dynamic_lookup. Please check your Makefile carefully.

Cheers, Fons.

Dear Fons,

As I have already mentioned my Makefile does “include Makefile.arch” from the root/test directory, thus is uses “$(UNDEFOPT)”.
Now I realized that “macosx” and “macosxxlc” define UNDEFOPT, while “macosx64” and “macosxicc” do not. Thus I have changed it to:

ifeq ($(ARCH),macosx64)
# MacOS X >= 10.4 with gcc 64 bit mode (GNU gcc 4.*)
# Only specific option (-m64) comes from root-config
MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2)
ifeq ($(MACOSX_DEPLOYMENT_TARGET),)
MACOSXTARGET := MACOSX_DEPLOYMENT_TARGET=10.$(MACOSX_MINOR)
else
MACOSXTARGET := MACOSX_DEPLOYMENT_TARGET=$(MACOSX_DEPLOYMENT_TARGET)
endif
CXX           = g++
CXXFLAGS      = $(OPT2) -pipe -Wall -W -Woverloaded-virtual
LD            = $(MACOSXTARGET) g++
LDFLAGS       = $(OPT2)
UNDEFOPT      = dynamic_lookup
# The SOFLAGS will be used to create the .dylib,
# the .so will be created separately
ifeq ($(subst $(MACOSX_MINOR),,1234),1234)
DllSuf        = so
else
DllSuf        = dylib
endif
SOFLAGS       = -dynamiclib -single_module -undefined $(UNDEFOPT) -install_name $(CURDIR)/
endif

This did solve my problem, nevertheless I would appreciate if you would make the corresponding changes in “Makefile.arch” so that
people using this file do not experience this problem.

However, now I have another problem: While compilation works fine as standalone library, you may know that I have created an
R/Bioconductor package “xps” where the compilation is done from within R. Although the compilation works fine, it seems that
the compiled library “xps.so” cannot be loaded into R. I get the following error:

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared library '/Volumes/CoreData/CRAN/xps.Rcheck/xps/libs/x86_64/xps.so':
  dlopen(/Volumes/CoreData/CRAN/xps.Rcheck/xps/libs/x86_64/xps.so, 6): Symbol not found: __ZN10TCanvasImp11ShowMembersER16TMemberInspectorPc
  Referenced from: /Volumes/CoreData/CRAN/xps.Rcheck/xps/libs/x86_64/xps.so
  Expected in: flat namespace
 in /Volumes/CoreData/CRAN/xps.Rcheck/xps/libs/x86_64/xps.so
ERROR: loading failed

While I will ask the SIG-Mac mailing list what this error means, my question here is:
What does “__ZN10TCanvasImp11ShowMembersER16TMemberInspectorPc” mean?
Do you have any hint why “__ZN10TCanvasImp11ShowMembersER16TMemberInspectorPc” is not found?

Best regards
Christian

Dear Fons,

Meanwhile I did some extensive testing on both Leopard and Snow Leopard using the attached Makefiles:

  • Makefile.txt: this is the Makefile of my program which does “include Makefile.arch”
  • Makefile_old.arch.txt: this is the old Makefile.arch which I use since a couple of years w/o problem
  • Makefile_new.arch.txt: this is the Makefile.arch from root_v5.27/02 where I have added $(UNDEFOPT)

1, Test on Leopard using Makefile_old.arch.txt:

I did the test using root_v5.24/00 and using root_v5.27/02 with both “./configure macosx” and “./configure macosx64”,
and in all cases everything worked fine. I could compile “xps.so” and run it from within root as expected, see e.g.:

ROOT 5.27/02 (trunk@33229, Apr 27 2010, 11:38:29 on macosx64)

CINT/ROOT C/C++ Interpreter version 5.17.00, Dec 21, 2008
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .L macro4XPSLeopard.C
root [1] Init("/Users/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so")
root [2] RMATest3("tmp_Test3_rma","/Users/rabbitus/ROOT/rootdata/test")
Creating new temporary file </Users/rabbitus/ROOT/rootdata/test/tmp_Test3_rma.root>...

2, Test on Leopard using Makefile_new.arch.txt:

With “./configure macosx” I could compile my program but get the following runtime error:

ROOT 5.27/02 (trunk@33229, Apr 27 2010, 11:38:29 on macosx)

CINT/ROOT C/C++ Interpreter version 5.17.00, Dec 21, 2008
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .L macro4XPSLeopard.C
root [1] Init("/Users/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so")
root [2] RMATest3("tmp_Test3_rma","/Users/rabbitus/ROOT/rootdata/test")
dyld: lazy symbol binding failed: Symbol not found: __ZN5TTree14SetMaxTreeSizeEx
  Referenced from: /Users/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so
  Expected in: dynamic lookup

dyld: Symbol not found: __ZN5TTree14SetMaxTreeSizeEx
  Referenced from: /Users/rabbitus/ROOT/rootcode/xps-x.x.x/src/xps.so
  Expected in: dynamic lookup

However, with “./configure macosx64” I get the following compilation problem:

g++ -dynamiclib -single_module -undefined dynamic_lookup -install_name /Users/rabbitus/ROOT/rootcode/xps-x.x.x/src/ TMLMath.o TStat.o StatUtils.o XPSBase.o XPSUtils.o XPSSchemes.o XPSDataTypes.o XPSProjectHandler.o XPSData.o XPSProcessing.o XPSHybridizer.o XPSSelector.o XPSNormalizer.o XPSPreProcessing.o XPSNormation.o XPSFilter.o XPSAnalyzer.o XPSAnalysis.o rwrapper.o xpsDict.o -L/Users/rabbitus/ROOT/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lfreetype -lGui -pthread -Wl,-rpath,/Users/rabbitus/ROOT/root/lib -lm -ldl  -lRIO -lGed -lTreePlayer -lTreeViewer -o  xps.so 
ld warning: in TMLMath.o, file is not of required architecture
ld warning: in TStat.o, file is not of required architecture
ld warning: in StatUtils.o, file is not of required architecture
ld warning: in XPSBase.o, file is not of required architecture
ld warning: in XPSUtils.o, file is not of required architecture
ld warning: in XPSSchemes.o, file is not of required architecture
ld warning: in XPSDataTypes.o, file is not of required architecture
ld warning: in XPSProjectHandler.o, file is not of required architecture
ld warning: in XPSData.o, file is not of required architecture
ld warning: in XPSProcessing.o, file is not of required architecture
ld warning: in XPSHybridizer.o, file is not of required architecture
ld warning: in XPSSelector.o, file is not of required architecture
ld warning: in XPSNormalizer.o, file is not of required architecture
ld warning: in XPSPreProcessing.o, file is not of required architecture
ld warning: in XPSNormation.o, file is not of required architecture
ld warning: in XPSFilter.o, file is not of required architecture
ld warning: in XPSAnalyzer.o, file is not of required architecture
ld warning: in XPSAnalysis.o, file is not of required architecture
ld warning: in rwrapper.o, file is not of required architecture
ld warning: in xpsDict.o, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libCore.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libCint.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libRIO.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libNet.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libHist.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libGraf.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libGraf3d.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libGpad.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libTree.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libRint.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libPostscript.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libMatrix.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libPhysics.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libMathCore.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libThread.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libfreetype.a, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libGui.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libGed.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libTreePlayer.so, file is not of required architecture
ld warning: in /Users/rabbitus/ROOT/root/lib/libTreeViewer.so, file is not of required architecture
g++ -bundle -undefined dynamic_lookup -O2 -m64 TMLMath.o TStat.o StatUtils.o XPSBase.o XPSUtils.o XPSSchemes.o XPSDataTypes.o XPSProjectHandler.o XPSData.o XPSProcessing.o XPSHybridizer.o XPSSelector.o XPSNormalizer.o XPSPreProcessing.o XPSNormation.o XPSFilter.o XPSAnalyzer.o XPSAnalysis.o rwrapper.o xpsDict.o \
                   -o  xps.so

3, Test on Snow Leopard using Makefile_old.arch.txt:

With “./configure macosx” I get the following compilation error:

c++ -dynamiclib -single_module -undefined suppress TMLMath.o TStat.o StatUtils.o XPSBase.o XPSUtils.o XPSSchemes.o XPSDataTypes.o XPSProjectHandler.o XPSData.o XPSProcessing.o XPSHybridizer.o XPSSelector.o XPSNormalizer.o XPSPreProcessing.o XPSNormation.o XPSFilter.o XPSAnalyzer.o XPSAnalysis.o rwrapper.o xpsDict.o -L/Volumes/CoreData/ROOT/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lfreetype -lGui -pthread -Wl,-rpath,/Volumes/CoreData/ROOT/root/lib -lm -ldl  -lRIO -lGed -lTreePlayer -lTreeViewer -o  xps.dylib 
ld: can't use -undefined warning or suppress with -twolevel_namespace
collect2: ld returned 1 exit status
make: *** [xps.dylib] Error 1

In contrast, with “./configure macosx64” I can compile my program but get the following runtime error:

ROOT 5.27/02 (trunk@33229, Apr 27 2010, 11:38:29 on macosx64)

CINT/ROOT C/C++ Interpreter version 5.17.00, Dec 21, 2008
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .L macro4XPS.C
root [1] Init("/Volumes/CoreData/ROOT/rootcode/xps-x.x.x/src_splice/xps.so")
root [2] RMATest3("tmp_Test3_rma","/Volumes/CoreData/ROOT/rootdata/testAB/xps-1.x.x")
dyld: lazy symbol binding failed: Symbol not found: __ZN5TTree14SetMaxTreeSizeEx
  Referenced from: /Volumes/CoreData/ROOT/rootcode/xps-x.x.x/src_splice/xps.so
  Expected in: flat namespace

dyld: Symbol not found: __ZN5TTree14SetMaxTreeSizeEx
  Referenced from: /Volumes/CoreData/ROOT/rootcode/xps-x.x.x/src_splice/xps.so
  Expected in: flat namespace

4, Test on Snow Leopard using Makefile_new.arch.txt:

With “./configure macosx” I get the following compilation problem:

g++ -dynamiclib -single_module -undefined dynamic_lookup -install_name /Volumes/CoreData/ROOT/rootcode/xps-x.x.x/src_splice/ TMLMath.o TStat.o StatUtils.o XPSBase.o XPSUtils.o XPSSchemes.o XPSDataTypes.o XPSProjectHandler.o XPSData.o XPSProcessing.o XPSHybridizer.o XPSSelector.o XPSNormalizer.o XPSPreProcessing.o XPSNormation.o XPSFilter.o XPSAnalyzer.o XPSAnalysis.o rwrapper.o xpsDict.o -L/Volumes/CoreData/ROOT/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lfreetype -lGui -pthread -Wl,-rpath,/Volumes/CoreData/ROOT/root/lib -lm -ldl  -lRIO -lGed -lTreePlayer -lTreeViewer -o  xps.so 
ld: warning: in TMLMath.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in TStat.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in StatUtils.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSBase.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSUtils.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSSchemes.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSDataTypes.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSProjectHandler.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSData.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSProcessing.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSHybridizer.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSSelector.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSNormalizer.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSPreProcessing.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSNormation.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSFilter.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSAnalyzer.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in XPSAnalysis.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in rwrapper.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in xpsDict.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libCore.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libCint.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libRIO.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libNet.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libHist.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libGraf.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libGraf3d.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libGpad.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libTree.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libRint.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libPostscript.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libMatrix.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libPhysics.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libMathCore.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libThread.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libfreetype.a, file was built for unsupported file format which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libGui.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libGed.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libTreePlayer.so, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Volumes/CoreData/ROOT/root/lib/libTreeViewer.so, file was built for i386 which is not the architecture being linked (x86_64)
g++ -bundle -undefined dynamic_lookup -O2 -m32 TMLMath.o TStat.o StatUtils.o XPSBase.o XPSUtils.o XPSSchemes.o XPSDataTypes.o XPSProjectHandler.o XPSData.o XPSProcessing.o XPSHybridizer.o XPSSelector.o XPSNormalizer.o XPSPreProcessing.o XPSNormation.o XPSFilter.o XPSAnalyzer.o XPSAnalysis.o rwrapper.o xpsDict.o \
                   -o  xps.so

In contrast, with “./configure macosx64” I can compile my program but get the following runtime error:

ROOT 5.27/02 (trunk@33229, Apr 27 2010, 11:38:29 on macosx64)

CINT/ROOT C/C++ Interpreter version 5.17.00, Dec 21, 2008
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .L macro4XPS.C
root [1] Init("/Volumes/CoreData/ROOT/rootcode/xps-x.x.x/src_splice/xps.so")
root [2] RMATest3("tmp_Test3_rma","/Volumes/CoreData/ROOT/rootdata/testAB/xps-1.x.x")
dyld: lazy symbol binding failed: Symbol not found: __ZN5TTree14SetMaxTreeSizeEx
  Referenced from: /Volumes/CoreData/ROOT/rootcode/xps-x.x.x/src_splice/xps.so
  Expected in: flat namespace

dyld: Symbol not found: __ZN5TTree14SetMaxTreeSizeEx
  Referenced from: /Volumes/CoreData/ROOT/rootcode/xps-x.x.x/src_splice/xps.so
  Expected in: flat namespace

In summary, while “Makefile_old.arch.txt” does work on Tiger and Leopard but not on Snow Leopard, the new “Makefile_new.arch.txt”
does not work on Leopard nor on Snow Leopard.

Can you tell me what I need to change to get “Makefile_old.arch.txt” to work on Snow Leopard, too?

Why does “Makefile_new.arch.txt” not work?

Best regards
Christian
Makefile.txt (3.48 KB)
Makefile_old.arch.txt (12.4 KB)
Makefile_new.arch.txt (12.9 KB)

Hi Christian,

you need to use the current Makefile.arch for all platforms, the old one does not support 10.6 as it only checks for versions up to 10.5. Now a number of errors are due to mixing 32 and 64 bit versions at link time:

ld: warning: in XPSData.o, file was built for i386 which is not the architecture being linked (x86_64)

Make sure you set the right ROOTSYS, PATH and DYLD_LIBRARY_PATH when building your program. You can use:

or

to switch.

Next make sure that if your xps lib depends on libTree, you link it with libTree.

Cheers, Fons.

Dear Fons,

Thank you, however it turns out that in order to use the new Makefile.arch I need to change my Makefile from:

ifeq ($(PLATFORM),macosx)
		$(LD) $(SOFLAGS) $^ $(GLIBS) $(MYLIBS) $(OutPutOpt) $@ 
ifeq ($(MACOSX_MINOR),4)
		ln -sf $@ $(subst .$(DllSuf),.so,$@)
else
		$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \
		   $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
endif

to:

ifeq ($(PLATFORM),macosx)
		$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(GLIBS) $(MYLIBS) $(OutPutOpt) $@
ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
ifeq ($(MACOSX_MINOR),4)
		ln -sf $@ $(subst .$(DllSuf),.so,$@)
else
		$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \
		   $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
endif
endif

although it is not quite clear to me why I needed to change the first part.

Best regards
Christian

Hi Christian,

this change was needed due to some refactoring and now LDFLAGS are needed.

ifneq ($(subst $(MACOSX_MINOR),,1234),1234) ifeq ($(MACOSX_MINOR),4) ln -sf $@ $(subst .$(DllSuf),.so,$@) else $(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \ $(OutPutOpt) $(subst .$(DllSuf),.so,$@) endif endif
is needed because on >= 10.5 there is no need anymore for separate .so and .dylib’s, just .so’s will do do.

Cheers, Fons.

Dear Fons,

Thank you for your explanation.

Best regards
Christian