Error compiling root_v5.24/00 on MacOS X Leopard

Dear MacRooters,

While I do not have any problems to compile root_v5.24/00 on MacOS X Tiger I am not able to compile it on Leopard.
It does not matter if I “configure macosx” or “configure macosx64” the error message is always the same:

....
Install proofserv wrapper.
bin/rmkdepend -R -fmain/src/hadd.d -Y -w 1000 -- -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude   -D_REENTRANT -pthread -D__cplusplus -- main/src/hadd.cxx
g++ -O2 -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude   -D_REENTRANT -pthread  -o main/src/hadd.o -c main/src/hadd.cxx
g++ -O2 -m64 -o bin/hadd main/src/hadd.o  \
                   -Llib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lMatrix -lMathCore -lThread -lm -Wl,-rpath,@loader_path/../lib    -pthread -ldl
bin/rmkdepend -R -fmain/src/ssh2rpd.d -Y -w 1000 -- -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude   -D_REENTRANT -pthread -D__cplusplus -- main/src/ssh2rpd.cxx
g++ -O2 -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude   -D_REENTRANT -pthread  -o main/src/ssh2rpd.o -c main/src/ssh2rpd.cxx
g++ -O2 -m64 -o bin/ssh2rpd main/src/ssh2rpd.o core/clib/src/snprintf.o -lm -Wl,-rpath,@loader_path/../lib    -pthread -ldl
bin/rmkdepend -R -fmain/src/roots.d -Y -w 1000 -- -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude   -D_REENTRANT -pthread -D__cplusplus -- main/src/roots.cxx
g++ -O2 -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude   -D_REENTRANT -pthread  -o main/src/roots.o -c main/src/roots.cxx
g++ -O2 -m64 -o bin/roots.exe main/src/roots.o  \
                   -Llib -lCore -lCint -lMathCore -lm -Wl,-rpath,@loader_path/../lib    -pthread -ldl
Install roots wrapper.
bin/rmkdepend -R -fmain/src/h2root.d -Y -w 1000 -- -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude   -D_REENTRANT -pthread -D__cplusplus -- main/src/h2root.cxx
g++ -O2 -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude   -D_REENTRANT -pthread  -o main/src/h2root.o -c main/src/h2root.cxx
g++ -O2 -m64 -o bin/h2root main/src/h2root.o  \
                   -Llib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lMatrix -lMathCore -lThread lib/libminicern.so \
                   /usr/local/lib/gcc/i686-apple-darwin8/4.2.3/../../../x86_64/libgfortran.dylib /usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64/libgfortranbegin.a -lm -Wl,-rpath,@loader_path/../lib    -pthread -ldl
gfortran -O2 -m64 -std=legacy -o main/src/g2root.o -c main/src/g2root.f
gfortran -O2 -m64 -o bin/g2root main/src/g2root.o \
                   -Llib lib/libminicern.so \
                   /usr/local/lib/gcc/i686-apple-darwin8/4.2.3/../../../x86_64/libgfortran.dylib /usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64/libgfortranbegin.a -lm -Wl,-rpath,@loader_path/../lib    -pthread -ldl
ld: -rpath can only be used when targeting Mac OS X 10.5 or later
collect2: ld returned 1 exit status
make: *** [bin/g2root] Error 1
rm core/utils/src/RStl_tmp.cxx core/utils/src/rootcint_tmp.cxx

Does anybody know what the reason for this error could be?

I am using MacOS X 10.5.5 and XCode 3.1.1 with gcc version 4.0.1 (Apple Inc. build 5488), gcc -v:

Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc/gcc-5488~2/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic --host=i686-apple-darwin9 --target=i686-apple-darwin9
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5488)

It is strange that gcc -v has as target “i686-apple-darwin9” but gfortran has as target “i686-apple-darwin8”, see gfortran -v:

Using built-in specs.
Target: i686-apple-darwin8
Configured with: /Builds/unix/gcc/gcc-4.2/configure --prefix=/usr/local --mandir=/share/man --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --build=i686-apple-darwin8 --host=i686-apple-darwin8 --target=i686-apple-darwin8 --enable-languages=fortran
Thread model: posix
gcc version 4.2.3

Is this correct or could this be the problem?

Best regards
Christian

Ypur gfortran is too old. Please upgrade to the latest version coming with gcc-4.4 in Fink.

Cheers, Fons.

Dear Fons,

Thank you for your suggestion, however I want to avoid using fink:

First, since using Tiger on Intel-Mac I am glad that I no longer need fink and having to use fink on Leopard would mean one step backwards.

Second, for R which I also need, since my program is an R package, fink is not recommended, see the answer to my question:
stat.ethz.ch/pipermail/r-sig-ma … 07030.html

Do you think that I can use one of the options mentioned in: r.research.att.com/tools/

For example for gfortran-4.2-5564-darwin9.tar.gz the version gives:

Using built-in specs.
Target: i686-apple-darwin9
Configured with: /Builds/gcc/gcc_42-5564/build/obj/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/usr/share/man --enable-languages=c,objc,c++,obj-c++,fortran --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-gxx-include-dir=/usr/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --host=i686-apple-darwin9 --target=i686-apple-darwin9
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5564)

This is supposed to be version fortran 4.2.4, see: stat.ethz.ch/pipermail/r-sig-ma … 07033.html
Do you think that this version will work?

Alternatively, is there a possibility to compile root w/o gfortran by disabling some options during configure?

Best regards
Christian

Dear Fons,

Meanwhile I have installed gfortran-4.2-5564-darwin9.tar.gz from r.research.att.com/tools/
and tried to compile root_v5.24/00 with the following options:

./configure macosx64 --with-cc="/usr/bin/gcc-4.2 -arch x86_64" --with-cxx="/usr/bin/g++-4.2 -arch x86_64" --with-f77="/usr/bin/gfortran-4.2 -arch x86_64"
make

This resulted in the following error:

*** Building graf2d/freetype/src/freetype-2.3.5/objs/.libs/libfreetype.a...
/bin/sh: -arch: command not found

FreeType build system -- automatic system detection

The following settings are used:

  platform                    unix
  compiler                    cc
  configuration directory     ./builds/unix
  configuration rules         ./builds/unix/unix.mk

If this does not correspond to your system or settings please remove the file
`config.mk' from this directory then read the INSTALL file for help.

Otherwise, simply type `make' again to build the library,
or `make refdoc' to build the API reference (the latter needs python).

Generating modules list in ./objs/ftmodule.h...
* module: truetype  (Windows/Mac font files with extension *.ttf or *.ttc)
* module: type1     (Postscript font files with extension *.pfa or *.pfb)
* module: cff       (OpenType fonts with extension *.otf)
* module: cid       (Postscript CID-keyed fonts, no known extension)
* module: pfr       (PFR/TrueDoc font files with extension *.pfr)
* module: type42    (Type 42 font files with no known extension)
* module: winfnt    (Windows bitmap fonts with extension *.fnt or *.fon)
* module: pcf       (pcf bitmap fonts)
* module: bdf       (bdf bitmap fonts)
* module: sfnt      (helper module for TrueType & OpenType formats)
* module: autofit   (automatic hinting module)
* module: pshinter  (Postscript hinter module)
* module: raster    (monochrome bitmap renderer)
* module: smooth    (anti-aliased bitmap renderer)
* module: smooth    (anti-aliased bitmap renderer for LCDs)
* module: smooth    (anti-aliased bitmap renderer for vertical LCDs)
* module: psaux     (Postscript Type 1 & Type 2 helper module)
* module: psnames   (Postscript & Unicode Glyph name handling)
done.
cd builds/unix; ./configure  "--with-pic" "CC="" "-m64"" "CFLAGS="-m64" "-O""
checking build system type... i386-apple-darwin9.5.0
checking host system type... i386-apple-darwin9.5.0
checking target system type... i386-apple-darwin9.5.0
checking for gcc...  -m64
checking for C compiler default output file name... 
configure: error: C compiler cannot create executables
See `config.log' for more details.
make[1]: *** [setup] Error 77
config.mk:25: builds/unix/unix-def.mk: No such file or directory
config.mk:26: builds/unix/unix-cc.mk: No such file or directory
make[1]: *** No rule to make target `builds/unix/unix-cc.mk'.  Stop.
make: *** [graf2d/freetype/src/freetype-2.3.5/objs/.libs/libfreetype.a] Error 2
rm core/utils/src/RStl_tmp.cxx core/utils/src/rootcint_tmp.cxx

As far as I understand the error this means that FreeType cannot be built for 64 bit. Is this correct?

Next I tried to compile root as follows:

./configure macosx64 --with-cxx="/usr/bin/g++-4.2 -arch x86_64" --with-f77="/usr/bin/gfortran-4.2 -arch x86_64"
make

Now I got the following error:

g++ -dynamiclib -single_module -undefined dynamic_lookup -install_name @rpath/libminicern.so -O2 -m64 -o lib/libminicern.so misc/minicern/src/cernlib.o -ldl misc/minicern/src/hbook.o misc/minicern/src/kernlib.o misc/minicern/src/zebra.o libgfortran.dylib /usr/lib/gcc/i686-apple-darwin9/4.2.1/libgfortranbegin.a
i686-apple-darwin9-g++-4.2.1: libgfortran.dylib: No such file or directory
make: *** [lib/libminicern.so] Error 1
rm core/utils/src/RStl_tmp.cxx core/utils/src/rootcint_tmp.cxx

Since gfortran-4.2 does not contain libgfortran.dylib I modified F77LIBS in “Makefile.macosx64” from:

F77LIBS      := $(shell $(F77) -m64 -print-file-name=libgfortran.dylib)
F77LIBS      += $(shell $(F77) -m64 -print-file-name=libgfortranbegin.a)

to:

F77LIBS      := $(shell $(F77) -m64 -print-file-name=libgfortranbegin.a)

Now I could finally compile “lib/libminicern.so” but I got the following error:

Options to Xrootd-configure:  --ccflavour=macos64 --with-ssl-shared=yes --disable-krb4 --enable-echo --no-arch-subdirs --disable-mon --with-cxx=/usr/bin/g++-4.2 -arch x86_64 --with-ld=g++ 
Guessing architecture/compiler: darwin:i386:9.5.0
darwin | i386 | 9.5.0 | x86_64_macosx | macos64
Invalid option '-arch'. Try ./configure.classic --help
*** Error condition reported by Xrootd-configure (rc = 1): rm -f net/xrootd/src/xrootd/GNUmakefile exit 1
*** Building xrootd ... topdir= /Users/rabbitus/ROOT/root
make[1]: *** No targets specified and no makefile found.  Stop.
*** Error condition reported by make (rc = 2): rm -f net/xrootd/src/xrootd/GNUmakefile exit 1

Thus it seems that xrootd cannot be compiled for 64 bit either. Is this correct?

For this reason I disabled xrootd using:

./configure macosx64 --with-cxx="/usr/bin/g++-4.2 -arch x86_64" --with-f77="/usr/bin/gfortran-4.2 -arch x86_64" --disable-xrootd
make

Now it seems that I could finally compile root for 64 bit.

However, I got the following link error:

Install roots wrapper.
bin/rmkdepend -R -fmain/src/h2root.d -Y -w 1000 -- -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude   -D_REENTRANT -pthread -D__cplusplus -- main/src/h2root.cxx
/usr/bin/g++-4.2 -arch x86_64 -O2 -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude   -D_REENTRANT -pthread  -o main/src/h2root.o -c main/src/h2root.cxx
g++ -O2 -m64 -o bin/h2root main/src/h2root.o  \
		   -Llib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lMatrix -lMathCore -lThread lib/libminicern.so \
		   /usr/lib/gcc/i686-apple-darwin9/4.2.1/libgfortranbegin.a -lm -Wl,-rpath,@loader_path/../lib    -pthread -ldl
ld warning: in /usr/lib/gcc/i686-apple-darwin9/4.2.1/libgfortranbegin.a, file is not of required architecture
/usr/bin/gfortran-4.2 -arch x86_64 -O2 -m64 -std=legacy -o main/src/g2root.o -c main/src/g2root.f
/usr/bin/gfortran-4.2 -arch x86_64 -O2 -m64 -o bin/g2root main/src/g2root.o \
		   -Llib lib/libminicern.so \
		   /usr/lib/gcc/i686-apple-darwin9/4.2.1/libgfortranbegin.a -lm -Wl,-rpath,@loader_path/../lib    -pthread -ldl
ld warning: in /usr/lib/gcc/i686-apple-darwin9/4.2.1/libgfortranbegin.a, file is not of required architecture
Undefined symbols:
  "_main", referenced from:
      start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [bin/g2root] Error 1
rm core/utils/src/RStl_tmp.cxx core/utils/src/rootcint_tmp.cxx

Searching google I found the following link: lists.apple.com/archives/Fortran … 00012.html

All Mac (Unix??) executables are started through the C runtime library , crtX.x.xx.o. Cos UNIX is a C based system.

This runtime library endeavours to call a main() function which would be found in any C type program.

Fortran programs do not have a main() function so the Fortran runtime library, libgfortranbegin.a or whatever, provides a dummy main() function to keep the C runtime happy. 

Thus in my understanding the error means that ld is looking for main() in “/usr/lib/gcc/i686-apple-darwin9/4.2.1/libgfortranbegin.a” but
cannot find the version for 64 bit. Is this correct?

Do I need to change F77FLAGS or another setting in Makefile.macosx64?

Best regards
Christian

Dear Fons,

Finally I succeeded compiling root as 64 bit. I needed to install the following gfortran version:
r.research.att.com/tools/gfortra … in9.tar.gz

Furthermore, I deleted the following two lines of “Makefile.macosx64”:

F77LIBS      := $(shell $(F77) -m64 -print-file-name=libgfortran.dylib)
F77LIBS      += $(shell $(F77) -m64 -print-file-name=libgfortranbegin.a)

and compiled root_v5.24/00 with the following options:

./configure macosx64 --with-cxx="/usr/bin/g++-4.2" --with-f77="/usr/bin/gfortran-4.2" --disable-xrootd

as suggested by Simon, see: stat.ethz.ch/pipermail/r-sig-ma … 07046.html

Nevertheless, these questions remain:
Why can FreeType not be built for 64 bit?
Why can xrootd not be built for 64 bit?

Finally, please allow me to suggest to use this version of gfortran and abandon the fink version.
This has the advantage that the same version of gfortran can be used to build ROOT and R as 64 bit versions.

Best regards
Christian