-------------------------------------------------------------------------------- root_v3.01.00-cvs2001-05-03 on MacOS X Release 10.0.02 -------------------------------------------------------------------------------- As 0th try, I built ROOT from the current CVS source tree with your suggested modifications to cint/lib/stream/{stdiostr.h,strm.h}. I just needed to change -nostartfiles to -nostdlib for SOFLAGS defined in config/Makefile.macosx. All tests worked except for vmatrix and vvector which require creation of a TApplication object in their main's: this problem persists so see "1st Try" for more detail. Also note that in order to make x3d and OpenGL work, I needed to add GLLIBEXTRA = $(OPENGLLIBDIR) $(OPENGLULIB) $(OPENGLLIB) \ -lXmu -lXext -lX11 X3DLIBEXTRA = -L/usr/X11R6/lib -lX11 in config/Makefile.macosx. Anyway, given this as a fall back solution, I moved on to real shared lib creation. ------- 1st Try ------- Strategy -------- Use SOFLAGS = -dynamiclib -undefined suppress -nodefaultlibs -install_name in config/Makefile.macosx and add $(SONAME) in build/unix/maklib.sh for all shared libraries but libCore.dylib which should not be linked with libcc_dynamic.a, since otherwise you get a "multiply defined symbols error" for ___builtin_delete, etc. in running root executables like: dyld: jsf multiple definitions of symbol ___builtin_vec_new /proj/soft/jsf/pro/lib/libJSF.dylib(opvnew.o) definition of ___builtin_vec_new /opt/root/pro/lib/libCore.dylib(opvnew.o) definition of ___builtin_vec_new For libCore.dylib I thus used -nostdlib instead of -nodefaultlibs, but this causes a "relocatable symbols (restFP and saveFP) in read-only section error": ld: base/src/TApplication.o has external relocation entries in non-writable section (__TEXT,__text) for symbols: restFP saveFP /usr/bin/libtool: internal link edit command failed These two assembler routines save and restore floating points and are part of libcc_dynamic.a. In order to avoid this error, they have to be bound in linking libCore.dylib. I thus decided to extract the module containg these symbols (macosx-fpsave.o) as $ ar -x /usr/lib/libcc_dynamic.a lib/macosx-fpsave.o and add this as CORELIBEXTRA. Avoid inline functions in libMatrix following R__HPUX, to make -fno-common effective, or your get an error in creating any shared libraries using libMatrix including itself: ld: common symbols not allowed with MH_DYLIB output format Note that Apple's ld does not seem to allow local static variables like TMatrix::err in any inline function. I am not quite sure whether this is a linker bug or feature. Anyway, with these modifications I could create real shared libs for all but libGX11, which has to do with libX11.a(globals.o): I think this will be solved when we moved to a shared version of X11. Since we only need a dynamically loadable module (so called bundle) for libGX11, I will ignore this problem for a while. Note added: If one wants to activate x3d and OpenGL, it's necessary to define X3DLIBEXTRA = -L/usr/X11R6/lib -lX11 GLLIBEXTRA = $(OPENGLLIBDIR) $(OPENGLULIB) $(OPENGLLIB) -lXmu -lXext -lX11 which makes their shared lib generations fail by the same token. We only need bundle files for them, so I will igonore this problem, too. Conditions ---------- config/Makefile.macosx SOFLAGS = -dynamiclib -undefined suppress -nodefaultlibs -install_name CORELIBEXTRA = $(ROOTSYS)/lib/macosx-fpsave.o GLLIBEXTRA = $(OPENGLLIBDIR) $(OPENGLULIB) $(OPENGLLIB) \ -lXmu -lXext -lX11 X3DLIBEXTRA = -L/usr/X11R6/lib -lX11 Makefile Special rule for CORELIB SOFLAGS = -dynamiclib -undefined suppress -nostdlib -install_name with CORELIBEXTRA = $(ROOTSYS)/lib/macosx-fpsave.o as defined in config/Makefile.macosx matrix/{inc/*.h,src/*.cxx} No inline functions with static local variables err as with HPUX Results ------- $ ./stress -b 20 OK $ ./bench -b OK $ ./vlazy OK $ ./vmatrix NG .... ---> Test matrix I/O Write matrix m to database Error in : TObject, unknow type: UInt_t fUniqueID Error in : TObject, unknow type: UInt_t fBits Error in : TMatrix, unknow type: Int_t fNrows Error in : TMatrix, unknow type: Int_t fNcols Error in : TMatrix, unknow type: Int_t fNelems Error in : TMatrix, unknow type: Int_t fRowLwb Error in : TMatrix, unknow type: Int_t fColLwb Error in : TMatrix, discarding: Real_t* fElements, illegal [fNelems] (must be Int_t) Close database Open database in read-only mode and read matrix *** malloc_zone_malloc[2884]: argument too large: -4 Abort trap $ ./vvector NG ---> Test vector I/O Write vector v to database Error in : TObject, unknow type: UInt_t fUniqueID Error in : TObject, unknow type: UInt_t fBits Error in : TVector, unknow type: Int_t fNrows Error in : TVector, unknow type: Int_t fRowLwb Error in : TVector, discarding: Real_t* fElements, illegal [fNrows] (must be Int_t) Close database Open database in read-only mode and read vector Read vector should be same as original still in memory Error in : vector 1 not initialized Fatal: (*vr) == v violated at line 544 of `vvector.cxx' aborting Abort trap $ ./tstring OK $ ./tcollex OK $ ./tcollbm OK $ ./minexam NG Fatal in : ROOT system not initialized aborting Abort trap $ ./hworld NG Fatal in : ROOT system not initialized aborting Abort trap $ ./guitest NG Warning in : class TGObject allready in TClassTable Warning in : class TGClient allready in TClassTable Warning in : class TGWindow allready in TClassTable Warning in : class TGUnknownWindowHandler allready in TClassTable Warning in : class TGPicture allready in TClassTable Warning in : class TGSelectedPicture allready in TClassTable Warning in : class TGPicturePool allready in TClassTable Warning in : class TGDimension allready in TClassTable Warning in : class TGPosition allready in TClassTable Warning in : class TGLongPosition allready in TClassTable Warning in : class TGFrame allready in TClassTable Warning in : class TGCompositeFrame allready in TClassTable Warning in : class TGVerticalFrame allready in TClassTable Warning in : class TGHorizontalFrame allready in TClassTable Warning in : class TGMainFrame allready in TClassTable Warning in : class TGTransientFrame allready in TClassTable Warning in : class TGGroupFrame allready in TClassTable Warning in : class TGLayoutHints allready in TClassTable Warning in : class TGTableLayoutHints allready in TClassTable Warning in : class TGLayoutManager allready in TClassTable Warning in : class TGVerticalLayout allready in TClassTable Warning in : class TGHorizontalLayout allready in TClassTable Warning in : class TGRowLayout allready in TClassTable Warning in : class TGColumnLayout allready in TClassTable Warning in : class TGMatrixLayout allready in TClassTable Warning in : class TGTableLayout allready in TClassTable Warning in : class TGTileLayout allready in TClassTable Warning in : class TGListLayout allready in TClassTable Warning in : class TGListDetailsLayout allready in TClassTable Warning in : class TGString allready in TClassTable Warning in : class TGHotString allready in TClassTable Warning in : class TGWidget allready in TClassTable Warning in : class TGIcon allready in TClassTable Warning in : class TGLabel allready in TClassTable Warning in : class TGButton allready in TClassTable Warning in : class TGTextButton allready in TClassTable Warning in : class TGPictureButton allready in TClassTable Warning in : class TGCheckButton allready in TClassTable Warning in : class TGRadioButton allready in TClassTable Warning in : class TGButtonGroup allready in TClassTable Warning in : class TGVButtonGroup allready in TClassTable Warning in : class TGHButtonGroup allready in TClassTable Warning in : class TGTextBuffer allready in TClassTable Warning in : class TGTextEntry allready in TClassTable Warning in : class TGMsgBox allready in TClassTable Warning in : class TGMenuBar allready in TClassTable Warning in : class TGPopupMenu allready in TClassTable Warning in : class TGMenuTitle allready in TClassTable Warning in : class TGShutter allready in TClassTable Warning in : class TGShutterItem allready in TClassTable Warning in : class TGHorizontal3DLine allready in TClassTable Warning in : class TGVertical3DLine allready in TClassTable Warning in : class TGGC allready in TClassTable Warning in : class TGGCPool allready in TClassTable Warning in : class TGProgressBar allready in TClassTable Warning in : class TGHProgressBar allready in TClassTable Warning in : class TGVProgressBar allready in TClassTable *** Break *** bus error Abort trap $ root -l NG Fatal in : ROOT system not initialized aborting Abort trap Observations ------------ 1) vmatrix and vvector problems can be be solved by creating a TAppliation object in their main's. 2) It took me long time but I finally found out that the most problems originated from the strange way of MacOS X's dynamic linking. On MacOS X a shared library is not loaded as a whole, it behaves like a dynamically loadable archive. Moreover by defalut the dynamic linker delay linking untill really needed. I should have set "-Xlinker -bind_at_load" to force the dynamic linker not to be lazy! 3) However, (2) did not solve everything. Any shared library in which iomanip features are used complained a missing symbol: ___ls__H1Zi_R7ostreamRCt6smanip1ZX01_RB0 which looks like a private static variable internally used in iomanip.o and cannot be loaded. I could link it up by adding iomanip.o extracted from libstdc++.a but this caused multiply defined symbols somewhere else. So I was forced to eliminate iomanip routines from libHist and libGraf3d. ------------------------------ nth Try : n is a big number:^) ------------------------------ Conditions ---------- config/Makefile.macosx SOFLAGS = -dynamiclib -undefined suppress -nodefaultlibs -install_name LDFLAGS = $(EXTRA_LDFLAGS) -Xlinker -bind_at_load CORELIBEXTRA = $(ROOTSYS)/lib/macosx-fpsave.o GLLIBEXTRA = $(OPENGLLIBDIR) $(OPENGLULIB) $(OPENGLLIB) \ -lXmu -lXext -lX11 X3DLIBEXTRA = -L/usr/X11R6/lib -lX11 F77 = g77 F77LIBS = -lg2c build/unix/makelib.sh $LD $SOFLAGS $SONAME -o $LIB -ldl $OBJS $EXTRA $LD -bundle -undefined suppress -install_name $BUNDLE -o $BUNDLE -ldl $OBJS $EXTRA Makefile Special rule for CORELIB SOFLAGS = -dynamiclib -undefined suppress -nostdlib -install_name with CORELIBEXTRA = $(ROOTSYS)/lib/macosx-fpsave.o as defined in config/Makefile.macosx matrix/{inc/*.h,src/*.cxx} No inline functions with static local variables err as with HPUX g3d/src/TXTRU.cxx Avoid using iomanip facilities. hist/src/{TMultiDimFit.cxx, TPrincipal.cxx} Avoid using iomanip facilities. test/Makefile.in LDFLAGS = -Xlinker -bind_at_load test/{vmatrix.cxx, vvector.cxx} Create a TApplication object. x3d/src/x3d.c Make 16bit color sort of work. Results ------- $ cd test $ ./stress -b 20 OK $ ./bench -b OK $ ./vlazy OK $ ./vmatrix OK $ ./vvector OK $ ./tstring OK $ ./tcollex OK $ ./tcollbm OK $ ./minexam OK $ ./hworld OK $ ./guitest OK $ cd ../tutorials $ root -l ..... root [0] .x benchmarks.C OK Tetris and Hello also worked. Aclock didn't. $ ls -l bin/root.exe -rwxr-xr-x 1 fujiik staff 127816 May 5 16:21 root.exe $ otool -L bin/root.exe libCore.dylib (compatibility version 0.0.0, current version 0.0.0) libCint.dylib (compatibility version 0.0.0, current version 0.0.0) libHist.dylib (compatibility version 0.0.0, current version 0.0.0) libGraf.dylib (compatibility version 0.0.0, current version 0.0.0) libGraf3d.dylib (compatibility version 0.0.0, current version 0.0.0) libTree.dylib (compatibility version 0.0.0, current version 0.0.0) libMatrix.dylib (compatibility version 0.0.0, current version 0.0.0) libRint.dylib (compatibility version 0.0.0, current version 0.0.0) /usr/local/lib/libdl.dylib (compatibility version 0.0.0, current version 0.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 50.0.0) O.K. Now the size of the executable is reasonable and it is actually linked to real shared libraries. But more importantly, it works:^)