Root compilation with G++ on MacOS

Hello,

I need to compile ROOT with gcc/g++. I am having difficulty with the objective C libraries.

If I link a true g++ (installed with brew) to the command gg++ and the same for gcc -> ggcc - I can start to compile with

cmake ../ -DCMAKE_CXX_COMPILER=gg++ -DCMAKE_C_COMPILER=ggcc <the rest of my options>

The compilation gets about 70% done before it gives me an error that “Option ‘-O’ takes an integer argument”. I tracked this down. In ‘root/core/macosx/CMakeLists.txt’, there is a line

set_source_files_properties(${sources} COMPILE_FLAGS "-ObjC++ -std=c++11")

So g++ is not recognizing the Objective C flag. I’ve changed this line to

set_source_files_properties(${sources} COMPILE_FLAGS "-x objective-c++-header -lobjc -std=c++11")

Which is the g++ equivalent. I’ve also tried ‘-x objective-c++’. This attempt fails at around 70% with hundreds of errors. It basically looks like the compiler does not understand the Objective C++.

Has anyone had success in compiling ROOT from source with g++ on OSX (not clang)?

PS - As a side note, I believe ‘g++’ in /usr/bin on OSX is actually a link to clang - verified on my machine by typing ‘g++ --version’. This is why I installed g++ from brew and linked it to gg++.


ROOT Version: Github Master branch, commit # 2762a32
Platform: OSX
Compiler: GCC 8.1.0


Please note that building ROOT on OS X with GCC is not officially supported. There are many problems with this combination. That said, it may be the case that your GCC was not compiled with support for Objective C++ (as support for it is optional in GCC). If your GCC does have support for Objective C++, however, you may be able to compile ROOT. You may want to make sure that you are not using the wrong compiler by setting -DCMAKE_C_COMPILER=... -DCMAKE_CXX_COMPILER=... with full paths to the compilers you want to use.

1 Like

Thanks for the info. I think my best bet is to use ROOT compiled with clang and fix my downstream problems another way. Cheers!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.