Error compiling ROOT 5.34.05 on Mac OS X 10.7.5

Dear ROOTers,

On my MacBook Pro with OS X 10.7.5 and XCode 4.2.1 I tried to compile root_v5.34.05.source.tar.gz either with gcc or with clang:

First I tried to configure with:

./configure macosx64 --with-f77="/usr/bin/gfortran-4.2"

and realized that the default configure setting seems now to be clang and not gcc:

Configuring for macosx64
Checking for Fink/MacPorts directory ... 
Checking for GNU Make version >= 3.80 ... ok
Checking for C compiler ... clang
Checking for C++ compiler ... clang++
Checking for linker (LD) ... clang++
Checking for F77 compiler ... /usr/bin/gfortran-4.2

Why is this the case?

Thus, in order to compile with gcc I tried to configure with:

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

This seems not to be sufficient since I still get:

Configuring for macosx64
Checking for Fink/MacPorts directory ... 
Checking for GNU Make version >= 3.80 ... ok
Checking for C compiler ... clang
Checking for C++ compiler ... /usr/bin/g++-4.2
Checking for linker (LD) ... clang++
Checking for F77 compiler ... /usr/bin/gfortran-4.2

How do I have to set configure to avoid clang?

In any case when trying to compile root I get in both cases the same error:

clang++ -O2 -m64 -mmacosx-version-min=10.7 -o bin/rmkdepend build/rmkdepend/cppsetup.o build/rmkdepend/ifparser.o build/rmkdepend/include.o build/rmkdepend/main.o build/rmkdepend/parse.o build/rmkdepend/pr.o build/rmkdepend/mainroot.o
Running /Volumes/MitziData/ROOT/root/build/unix/compiledata.sh
Making include/compiledata.h
Running /Volumes/MitziData/ROOT/root/cint/ROOT/configcint.mk
Making cint/cint/inc/configcint.h
bin/rmkdepend -R -fcint/cint/src/g__cfunc.d -Y -w 1000 -- -m64 -pipe -W -Wall -fsigned-char -fno-common -Iinclude   -DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__ROOT -DG__REDIRECTIO -DG__OSFDLL -DG__STD_EXCEPTION  -DG__HAVE_CONFIG -DG__NOMAKEINFO -DG__CINTBODY  -I/Volumes/MitziData/ROOT/root/cint/cint/inc -I/Volumes/MitziData/ROOT/root/cint/cint/src -I/Volumes/MitziData/ROOT/root/cint/cint/src/dict -pthread -I. -- /Volumes/MitziData/ROOT/root/cint/cint/src/g__cfunc.c
clang -O2 -m64 -pipe -W -Wall -fsigned-char -fno-common -Iinclude   -DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__ROOT -DG__REDIRECTIO -DG__OSFDLL -DG__STD_EXCEPTION  -DG__HAVE_CONFIG -DG__NOMAKEINFO -DG__CINTBODY  -I/Volumes/MitziData/ROOT/root/cint/cint/inc -I/Volumes/MitziData/ROOT/root/cint/cint/src -I/Volumes/MitziData/ROOT/root/cint/cint/src/dict -pthread -I. -o cint/cint/src/g__cfunc.o -c /Volumes/MitziData/ROOT/root/cint/cint/src/g__cfunc.c
In file included from /Volumes/MitziData/ROOT/root/cint/cint/src/g__cfunc.c:38:
In file included from /Volumes/MitziData/ROOT/root/cint/cint/src/common.h:43:
In file included from include/G__ci.h:1621:
include/G__ci_fproto.h:19:19: error: token is not a valid binary operator in a preprocessor subexpression
# if __has_warning("-Wreturn-type-c-linkage")
     ~~~~~~~~~~~~~^
1 error generated.
make: *** [cint/cint/src/g__cfunc.o] Error 1

What does this error mean?

What do I need to do to compile root_v5.34.05 successfully on my Mac for:
a, gcc
b, clang

Best regards,
Christian

Dear All,

By searching ROOT support I realized that in order to compile ROOT with clang I need at least clang version 3.1, see:
[url]Compilation error for 5.34/00 on OS X 10.7.4

However, I still want to compile ROOT with gcc, too, so I did:

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

However, this resulted in following error:

Making cint/cint/inc/configcint.h
bin/rmkdepend -R -fcint/cint/src/g__cfunc.d -Y -w 1000 -- -m64 -pipe -W -Wall -fsigned-char -fno-common -Iinclude   -DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__ROOT -DG__REDIRECTIO -DG__OSFDLL -DG__STD_EXCEPTION  -DG__HAVE_CONFIG -DG__NOMAKEINFO -DG__CINTBODY  -I/Volumes/MitziData/ROOT/root/cint/cint/inc -I/Volumes/MitziData/ROOT/root/cint/cint/src -I/Volumes/MitziData/ROOT/root/cint/cint/src/dict -pthread -I. -- /Volumes/MitziData/ROOT/root/cint/cint/src/g__cfunc.c
make: bin/rmkdepend: No such file or directory
make: *** [cint/cint/src/g__cfunc.o] Error 1

Searching ROOT Support gave:
[url]MacOSX install problem
[url]Bin/rmkdepend: Command not found
But this did not help, since e.g. ‘make distclean’ did not help.

Please can anyone tell me how to compile root_v5.34.05 with gcc on may Mac?

FYI, this is the first version of ROOT which I cannot compile on my Mac, I had never any problems to compile root_v5.32.03 or earlier versions.

Best regards,
Christian

Hi Christian,

To compile purely with the gcc compilers use the configure options:

–with-cc=gcc
–with-cxx=g++
–with-ld=g++
–with-f77=gfortran

Note the linker has to be g++ otherwise the c++ runtime will not be linked in.

– Fons

I would recommend using http://alexpearce.me/2012/08/installing-root-on-mountain-lion/ site. Worked perfectly for me : )
Best of luck!
Natasha

Just to provide another usable option, I found the root package from MacPorts to be rather stable, and it provides variants for different compilers (gcc 4.X and clang). If you’re not used to makefiles then MacPorts basically handles it for you. If you are more familiar with compiling yourself, then possibly it’s overkill to bring in MacPorts.

Dear Fons and others,

Thank you for your reply, the suggestion of Fons did solve my problem:
I did not know that I have to use ‘–with-ld=g++’

Regarding the other thankful suggestions:

  • Luckily for Lion I do not need Homebrew, I don’t know if this will be necessary for Mavericks
  • Using MacPorts/Fink to compile root is a no-go for me

Best regards,
Christian