Symbol not found: ____ZN9TGedFr... (Mac Tiger Linking issue)

Dear ROOTers

Since I added to my library a method using class TParallelCoord, which needs library libTreeViewer, I have added the following code to my Makefile:

MYLIBS = -lTreeViewer

ifeq ($(PLATFORM),macosx)
		$(LD) $(SOFLAGS) $^ $(GLIBS) $(MYLIBS) $(OutPutOpt) $@ 
else
		$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(GLIBS) $(MYLIBS) $(OutPutOpt) $@ 
endif

When running make I get the following output:

MACOSX_DEPLOYMENT_TARGET=10.4 c++ -dynamiclib -single_module -undefined dynamic_lookup 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 -lpthread 
-lm -ldl  -lTreeViewer -o  xps.dylib 
ln -sf xps.dylib xps.so

As you see, library lTreeViewer is linked. However, when I load my library into root, I get the following error:

root [1] Init("/Volumes/CoreData/ROOT/rootcode/xps-x.x.x/src/xps.so")
dlopen error: dlopen(/Volumes/CoreData/ROOT/rootcode/xps-x.x.x/src/xps.so, 9): Symbol not found: __ZN9TGedFrame24ActivateBaseClassEditorsEP6TClass
  Referenced from: /Volumes/CoreData/ROOT/root/lib/libTreeViewer.dylib
  Expected in: dynamic lookup

Load Error: Failed to load Dynamic link library /Volumes/CoreData/ROOT/rootcode/xps-x.x.x/src/xps.so
(int)(-1)
*** Interpreter error recovered ***

Do you know the reason for this error?

Thank you in advance.
Best regards
Christian

P.S.: I am using root 5.20/00 on Intel-Mac Tiger.

Christian,

When linking with a library, you can see the list of dependencies of this library by looking at the corresponding rootmap file in $ROOTSYS/lib, eg in $ROOTSYS/lib/libTreeViewer.rootmap, you will find this:

Library.TTreeViewer: libTreeViewer.so libTree.so libGpad.so libGraf.so libHist.so libGui.so libTreePlayer.so libGed.so libRIO.so libMathCore.so

Rene

Dear Rene

Thank you, this was exactly what I wanted to know.

Since you(?) added “Mac Tiger Linking issue” to the subject, does this mean that this problem does not exist on Linux or Mac Leopard?

Best regards
Christian

On Linux, we recommend that instead of hard linking your library to a fix list of libraries, you create a rootmap file.

Philippe

Dear Philippe

I think that this is not possible since I need to use the same Makefile for Mac and Linux,
and I don’t think that R will be able to compile my package.

Furthermore, this does not answer my question if this problem also exists on Linux and Mac Leopard.

Best regards
Christian

[quote]Furthermore, this does not answer my question if this problem also exists on Linux and Mac Leopard. [/quote]Yes it turns out that you problem is not Tiger specific … If you use the same technique on Linux and newer Mac you will end with the same result.

Cheers,
Philippe.

Dear Philippe

Thank you, this info helps me changing my Makefile accordingly.

Best regards
Christian

Dear ROOTers

Now I have a question regarding my MakeFile.win, which I have changed as follows:

LDFLAGS       = $(LDOPT) $(conlflags) -nologo -include:_G__cpp_setupG__Hist \
                -include:_G__cpp_setupG__Graf1 -include:_G__cpp_setupG__G3D \
                -include:_G__cpp_setupG__GPad -include:_G__cpp_setupG__Tree \
                -include:_G__cpp_setupG__Rint -include:_G__cpp_setupG__PostScript \
                -include:_G__cpp_setupG__Matrix -include:_G__cpp_setupG__Physics
SOFLAGS       = $(dlllflags:-pdb:none=)
ROOTLIBS      = "${ROOTSYS}/lib/libCore.lib" \
                "${ROOTSYS}/lib/libCint.lib" "${ROOTSYS}/lib/libHist.lib" \
                "${ROOTSYS}/lib/libGraf.lib" "${ROOTSYS}/lib/libGraf3d.lib" \
                "${ROOTSYS}/lib/libGpad.lib" "${ROOTSYS}/lib/libTree.lib" \
                "${ROOTSYS}/lib/libRint.lib" "${ROOTSYS}/lib/libPostscript.lib" \
                "${ROOTSYS}/lib/libMatrix.lib" "${ROOTSYS}/lib/libPhysics.lib" \
                "$(ROOTSYS)/lib/libNet.lib" "$(ROOTSYS)/lib/libRIO.lib" \
                "$(ROOTSYS)/lib/libMathCore.lib"
LIBS          = $(ROOTLIBS)
GLIBS         = $(LIBS) "${ROOTSYS}/lib/libGui.lib" "${ROOTSYS}/lib/libGraf.lib" \
                "${ROOTSYS}/lib/libGpad.lib" "${ROOTSYS}/lib/libGed.lib" \
                "${ROOTSYS}/lib/libTreePlayer.lib" "${ROOTSYS}/lib/libTreeViewer.lib"

The question that I have is if I need to add also something to LDFLAGS?

More generally:
Looking at the main root Makefile I see that it is used to force linking of not referenced libraries.
What does “not referenced libraries” mean?
How do I know which libraries are not referenced?

Best regards
Christian

Hi,

On windows the linker pulls in from the library only the symbol that used directly or indirectly in the .o file that are passed.

For ROOT to function properly the dictionary needs to be loaded. However no code is referring to any of the symbol defined in the dictionary. So in order for the dictionary to be properly linked-in we need to explicit request them. This is done via the ‘-include:_G__cpp_setupG__Hist’ which request one of the symbol defined the dictionary for libHist. Usually the ROOT dictionary for a ROOT library XYZ is named G__XYZ and one symbol defined is _G__cpp_setupG__XYZ. So libGed you need to add -include:_G__cpp_setupG__Ged

Cheers,
Philippe.

Dear Philippe

Thank you for your explanation.
Interestingly, on WinXP my program works with the current setting of my Makefile, i.e. w/o adding -include:_G__cpp_setupG__Ged.
However, I will add it anyhow, but I do not understand why it works.

Best regards
Christian