Compiling v5-30-00 on Mac OS X with CMAKE fails

Hello,
When I try to compile the latest release of ROOT on my mac I get the following error –

Linking CXX shared library ../../lib/libHbook.so
ld: in /usr/local/lib/libgfortran.3.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [lib/libHbook.so] Error 1
make[1]: *** [hist/hbook/CMakeFiles/Hbook.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Could you please tell me what is going wrong here. I am using Mac OS X 10.6.8.

Here is the command I use to compile –

cmake $ROOTSYS -DGSL_CONFIG_EXECUTABLE=/Users/subho/Documents/Workshop/GSL/bin/gsl-config -Dmathmore=ON

make -j4

Cheers,
Subho.

Hi,

you’ve an old 32-bit version of gfortran installed. Please remove it and use Fink or MacPorts to install an up-to-date x86_64 version of gfortran.

Cheers, Fons.

Hi,
I have the two libgfortrans –

/usr/local/lib/libgfortran.a (32bit)

and

/usr/local/lib/x86_64/libgfortran.a (64 bit)

Is there any way of explicitly selecting the 64bit version of the archive in the compilation process?

Cheers,
Subho.

[EDIT]
Also, I forgot to mention this happens on the CMake build.
The old make based build system is able to manage this and root compiles successfully. However the CMake based one fails!

Very likely you have a 32 bit installation of gfortran. From CMake point of view there is no handle from where the internal libraries will be taken. CMake simply locates the compiler and use it.
In my installation if I do “gfortran -print-search-dirs” I get:

install: /usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/
programs: =/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin10.3.0/4.5.1/:/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin10.3.0/4.5.1/:/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin10.3.0/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/../../../../x86_64-apple-darwin10.3.0/bin/x86_64-apple-darwin10.3.0/4.5.1/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/../../../../x86_64-apple-darwin10.3.0/bin/
libraries: =/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/../../../../x86_64-apple-darwin10.3.0/lib/x86_64-apple-darwin10.3.0/4.5.1/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/../../../../x86_64-apple-darwin10.3.0/lib/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/../../../x86_64-apple-darwin10.3.0/4.5.1/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/../../../:/lib/x86_64-apple-darwin10.3.0/4.5.1/:/lib/:/usr/lib/x86_64-apple-darwin10.3.0/4.5.1/:/usr/lib/

Can you try to reinstall gfortran in your system making sure that is a x86_64 flavor?

Hi,
I get the 32 bit libraries if I use – gfortran -print-search-dirs

However, if I use – gfortran -m64 -print-search-dirs

I get the correct 64 bit libraries.

Cheers,
Subho

As far I can see the -m64 flag is applied for the macosx64 platform. Still the problem is during the linking (ld) it finds the file /usr/local/lib/libgfortran.3.dylib which is not adequate for the 64 architecture. Can you for a try remove (rename) the library in /usr/local/lib?

Hi,
I have installed a new version of gfortran with the libraries for x86_64 but the compilation still fails

$ gfortran -print-search-dirs

install: /sw/lib/gcc4.5/lib/gcc/x86_64-apple-darwin10.8.0/4.5.0/
programs: =/sw/lib/gcc4.5/libexec/gcc/x86_64-apple-darwin10.8.0/4.5.0/:/sw/lib/gcc4.5/libexec/gcc/x86_64-apple-darwin10.8.0/4.5.0/:/sw/lib/gcc4.5/libexec/gcc/x86_64-apple-darwin10.8.0/:/sw/lib/gcc4.5/lib/gcc/x86_64-apple-darwin10.8.0/4.5.0/:/sw/lib/gcc4.5/lib/gcc/x86_64-apple-darwin10.8.0/:/sw/lib/gcc4.5/lib/gcc/x86_64-apple-darwin10.8.0/4.5.0/../../../../x86_64-apple-darwin10.8.0/bin/x86_64-apple-darwin10.8.0/4.5.0/:/sw/lib/gcc4.5/lib/gcc/x86_64-apple-darwin10.8.0/4.5.0/../../../../x86_64-apple-darwin10.8.0/bin/
libraries: =/sw/lib/gcc4.5/lib/gcc/x86_64-apple-darwin10.8.0/4.5.0/:/sw/lib/gcc4.5/lib/gcc/x86_64-apple-darwin10.8.0/4.5.0/../../../../x86_64-apple-darwin10.8.0/lib/x86_64-apple-darwin10.8.0/4.5.0/:/sw/lib/gcc4.5/lib/gcc/x86_64-apple-darwin10.8.0/4.5.0/../../../../x86_64-apple-darwin10.8.0/lib/:/sw/lib/gcc4.5/lib/gcc/x86_64-apple-darwin10.8.0/4.5.0/../../../x86_64-apple-darwin10.8.0/4.5.0/:/sw/lib/gcc4.5/lib/gcc/x86_64-apple-darwin10.8.0/4.5.0/../../../:/lib/x86_64-apple-darwin10.8.0/4.5.0/:/lib/:/usr/lib/x86_64-apple-darwin10.8.0/4.5.0/:/usr/lib/

and the build fails at —

Linking CXX shared library ../../lib/libHbook.so
ld: in /usr/local/lib/libgfortran.3.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [lib/libHbook.so] Error 1
make[1]: *** [hist/hbook/CMakeFiles/Hbook.dir/all] Error 2
make: *** [all] Error 2

In addition to have installed a new version of gfortran, can you please remove the file /usr/local/lib/libgfortran.3.dylib in your system?