Trouble building ROOT 6.12.06 on macOS 10.13 with GCC 4.9

Dear ROOT experts,

I need to compile ROOT with GCC 4.9 on macOS and cannot make it work.

The help output of ROOT/configure indicating that macosx64 should do the trick and use GCC on a mac:

Usage:     ./configure [architecture] [flag=value]
...
Supported Architectures:
   macosx               for MacOS X >= 10.8 with clang, 32 bit mode
   macosxicc            for MacOS X >= 10.8 with Intel icc >= 13 (Intel only), 32 bit mode
   macosx64             for MacOS X >= 10.8 with gcc >= 4.8, 64 bit mode
...

However, typing “./configure macosx64” will ignore gcc and use clang instead.
So I did ./configure macosx64 --with-cc=gcc-4.9 --with-cxx=g++-4.9 --with-ld=g++-4.9 --with-f77=gfortran-4.9 which recognised my desired GCC, it started to compile (with gazillions of deprecation warnings, but never mind) and eventually stopped with a very weird error which indicates that in the -O2 flag, 2 is treated as a -2 or whatever is happening there:

g++-4.9 -O2 -DNDEBUG -m64 -std=c++11 -pipe -Wshadow -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude -DR__HAVE_CONFIG    -pthread  -Icore/base/src -DNDEBUG -MMD -MP -ObjC++ -o core/macosx/src/CocoaUtils.o -c /Users/tamasgal/tmp/root-6.10.08/core/macosx/src/CocoaUtils.mm
cc1objplus: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
make: *** [core/macosx/src/CocoaUtils.o] Error 1:

I could get around this by disabling Cocoa: ./configure macosx64 --with-cc=gcc-4.9 --with-cxx=g++-4.9 --with-ld=g++-4.9 --with-f77=gfortran-4.9 --disable-cocoa, but then I got another error a few steps later:

cp core/lz4/src/lz4-1.7.5/lib/liblz4.a lib/liblz4.a
g++-4.9 -O2 -DNDEBUG -m64 -std=c++11 -pipe -Wshadow -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude -DR__HAVE_CONFIG    -pthread  -Icore/base/src -DBUILTIN_LZ4 -Icore/lz4/src/lz4-1.7.5/lib -MMD -MP -o core/lz4/src/ZipLZ4.o -c /Users/tamasgal/tmp/root-6.10.08/core/lz4/src/ZipLZ4.cxx
*** Building interpreter/llvm/inst/lib/libclangSema.a...
make[1]: *** No targets specified and no makefile found.  Stop.
make: *** [interpreter/llvm/inst/lib/libclangSema.a] Error 2

I could not fix this one but found a post with a similar error, reported by a user who used CMake to compile ROOT. So I thought I try again from scratch with CMake and started the compilation with this command: cmake /path/to/root-6.12.06-sources -Dcocoa=OFF -Dx11=ON -DCMAKE_C_COMPILER=gcc-4.9 -DCMAKE_CXX_COMPILER=g++-4.9, and got the following error related to MySQL

In file included from input_line_12:9:
/Users/tamasgal/opt/root/6.12.06/include/TMySQLStatement.h:35:7: error: unknown type name 'my_bool'
      my_bool       fResNull;    //! indicates if argument is null
      ^
Error: /Users/tamasgal/opt/root/6.12.06/bin/rootcling: compilation failure (/Users/tamasgal/opt/root/6.12.06/lib/libRMySQL553259fc3d_dictUmbrella.h)
make[2]: *** [sql/mysql/G__RMySQL.cxx] Error 1
make[1]: *** [sql/mysql/CMakeFiles/G__RMySQL.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

I fixed this by renaming my_bool to bool (it was renamed in MySQL 8).

Finally, I got stuck with this message at 95%:

[ 95%] Linking CXX shared library ../../lib/libRDAVIX.so
Undefined symbols for architecture x86_64:
  "Davix::DavixError::setupError(Davix::DavixError**, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Davix::StatusCode::Code, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      TDavixFile_http_authn_cert_X509(void*, Davix::SessionInfo const&, Davix::X509Credential*, Davix::DavixError**) in TDavixFile.cxx.o
  "Davix::RequestParams::setAwsToken(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      decltype ((({parm#1}->setAwsToken)({parm#2})),((void)())) awsToken<Davix::RequestParams>(Davix::RequestParams*, char const*) in TDavixFile.cxx.o
  "Davix::RequestParams::setAwsRegion(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      decltype ((({parm#1}->setAwsRegion)({parm#2})),((void)())) awsRegion<Davix::RequestParams>(Davix::RequestParams*, char const*) in TDavixFile.cxx.o
  "Davix::RequestParams::setUserAgent(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      TDavixFileInternal::init()      in TDavixFile.cxx.o
  "Davix::RequestParams::setAwsAuthorizationKeys(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      TDavixFileInternal::setS3Auth(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in TDavixFile.cxx.o
      TDavixFileInternal::parseConfig()       in TDavixFile.cxx.o
  "Davix::RequestParams::addCertificateAuthorityPath(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      TDavixFileInternal::enableGridMode()       in TDavixFile.cxx.o
      TDavixFileInternal::parseConfig()       in TDavixFile.cxx.o
  "Davix::X509Credential::loadFromFilePEM(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Davix::DavixError**)", referenced from:
      TDavixFile_http_authn_cert_X509(void*, Davix::SessionInfo const&, Davix::X509Credential*, Davix::DavixError**) in TDavixFile.cxx.o
  "Davix::Uri::Uri(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      TDavixFileInternal::Open()      in TDavixFile.cxx.o
      TDavixSystem::Locate(char const*, TString&) in TDavixSystem.cxx.o
  "Davix::DavFile::getAllReplicas(Davix::RequestParams const*, std::deque<Davix::Replica, std::allocator<Davix::Replica> >&, Davix::DavixError**)", referenced from:
      TDavixSystem::Locate(char const*, TString&) in TDavixSystem.cxx.o
  "Davix::DavPosix::open(Davix::RequestParams const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, Davix::DavixError**)", referenced from:
      TDavixFileInternal::Open()      in TDavixFile.cxx.o
  "Davix::DavPosix::stat(Davix::RequestParams const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, stat*, Davix::DavixError**)", referenced from:
      TDavixFileInternal::DavixStat(char const*, stat*) in TDavixFile.cxx.o
  "Davix::DavPosix::mkdir(Davix::RequestParams const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned short, Davix::DavixError**)", referenced from:
      TDavixSystem::MakeDirectory(char const*) in TDavixSystem.cxx.o
  "Davix::DavPosix::unlink(Davix::RequestParams const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Davix::DavixError**)", referenced from:
      TDavixSystem::Unlink(char const*) in TDavixSystem.cxx.o
  "Davix::DavPosix::opendir(Davix::RequestParams const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Davix::DavixError**)", referenced from:
      TDavixSystem::OpenDirectory(char const*) in TDavixSystem.cxx.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libRDAVIX.so] Error 1
make[1]: *** [net/davix/CMakeFiles/RDAVIX.dir/all] Error 2
make: *** [all] Error 2

Any ideas why the linking is failing?


ROOT Version: 6.12.06
Platform: macOS 10.13
Compiler: GCC 4.9


I disabled Davix and also MySQL with -Ddavix=OFF -Dmysql=OFF but now got an other linker error from XrdCl. Btw. is there are way to reconfigure it with cmake without doing a fresh compilation from scratch? I tried running cmake with Davix disabled but it ignored it, so I had to wipe the build directory and wait another 2 hours to get to this error…

Now I will try to disable xrootd and rebuild again.

Undefined symbols for architecture x86_64:
  "XrdCl::FileSystem::Rm(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned short)", referenced from:
      TNetXNGSystem::Unlink(char const*) in TNetXNGSystem.cxx.o
  "XrdCl::FileSystem::Stat(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, XrdCl::StatInfo*&, unsigned short)", referenced from:
      TNetXNGSystem::Unlink(char const*) in TNetXNGSystem.cxx.o
      TNetXNGSystem::GetPathInfo(char const*, FileStat_t&) in TNetXNGSystem.cxx.o
  "XrdCl::FileSystem::MkDir(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, XrdCl::MkDirFlags::Flags, XrdCl::Access::Mode, unsigned short)", referenced from:
      TNetXNGSystem::MakeDirectory(char const*) in TNetXNGSystem.cxx.o
  "XrdCl::FileSystem::RmDir(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned short)", referenced from:
      TNetXNGSystem::Unlink(char const*) in TNetXNGSystem.cxx.o
  "XrdCl::FileSystem::Locate(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, XrdCl::OpenFlags::Flags, XrdCl::LocationInfo*&, unsigned short)", referenced from:
      TNetXNGSystem::Locate(char const*, TString&) in TNetXNGSystem.cxx.o
  "XrdCl::FileSystem::DirList(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, XrdCl::DirListFlags::Flags, XrdCl::DirectoryList*&, unsigned short)", referenced from:
      TNetXNGSystem::GetDirEntry(void*)   in TNetXNGSystem.cxx.o
  "XrdCl::FileSystem::Prepare(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, XrdCl::PrepareFlags::Flags, unsigned char, XrdCl::Buffer*&, unsigned short)", referenced from:
      TNetXNGSystem::Stage(TCollection*, unsigned char) in TNetXNGSystem.cxx.o
  "XrdCl::Env::PutInt(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
      TNetXNGFile::SetEnv()      in TNetXNGFile.cxx.o
  "XrdCl::Env::PutString(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      TNetXNGFile::SetEnv()      in TNetXNGFile.cxx.o
  "XrdCl::URL::URL(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      TNetXNGFile::GetVectorReadLimits()       in TNetXNGFile.cxx.o
      TNetXNGFile::TNetXNGFile(char const*, char const*, char const*, int, int, bool) in TNetXNGFile.cxx.o
      TNetXNGFile::TNetXNGFile(char const*, char const*, char const*, int, int, bool) in TNetXNGFile.cxx.o
      TNetXNGSystem::MakeDirectory(char const*) in TNetXNGSystem.cxx.o
      TNetXNGSystem::Unlink(char const*) in TNetXNGSystem.cxx.o
      TNetXNGSystem::GetPathInfo(char const*, FileStat_t&) in TNetXNGSystem.cxx.o
      TNetXNGSystem::ConsistentWith(char const*, void*) in TNetXNGSystem.cxx.o
      ...
  "XrdCl::File::VectorRead(std::vector<XrdCl::ChunkInfo, std::allocator<XrdCl::ChunkInfo> > const&, void*, XrdCl::ResponseHandler*, unsigned short)", referenced from:
      TNetXNGFile::ReadBuffers(char*, long long*, int*, int) in TNetXNGFile.cxx.o
  "XrdCl::File::Open(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, XrdCl::OpenFlags::Flags, XrdCl::Access::Mode, XrdCl::ResponseHandler*, unsigned short)", referenced from:
      TNetXNGFile::TNetXNGFile(char const*, char const*, char const*, int, int, bool) in TNetXNGFile.cxx.o
      TNetXNGFile::TNetXNGFile(char const*, char const*, char const*, int, int, bool) in TNetXNGFile.cxx.o
  "XrdCl::File::Open(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, XrdCl::OpenFlags::Flags, XrdCl::Access::Mode, unsigned short)", referenced from:
      TNetXNGFile::ReOpen(char const*) in TNetXNGFile.cxx.o
      TNetXNGFile::TNetXNGFile(char const*, char const*, char const*, int, int, bool) in TNetXNGFile.cxx.o
      TNetXNGFile::TNetXNGFile(char const*, char const*, char const*, int, int, bool) in TNetXNGFile.cxx.o
  "XrdCl::File::GetProperty(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&) const", referenced from:
      TNetXNGFile::GetVectorReadLimits()       in TNetXNGFile.cxx.o
ld: symbol(s) not found for architecture x86_64

This is where I am stuck now. I guess I need to try another Python version:

/Users/tamasgal/tmp/root/root-6.12.06/bindings/pyroot/src/PyRootType.cxx: In function 'PyObject* PyROOT::{anonymous}::pt_getattro(PyObject*, PyObject*)':
/Users/tamasgal/tmp/root/root-6.12.06/bindings/pyroot/src/PyRootType.cxx:103:67: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
                char* cppname = PyROOT_PyUnicode_AsString(pycppname);

Building with GCC on MacOS is not supported. Why do you need to use GCC?

The problem is that GCC is not compatible with system libraries or other libraries that have been compiled with Clang, that’s why you see all these std::basic_string linking issues. Please just use Clang if you can.

For your reference: https://gcc.gnu.org/onlinedocs/libstdc%2B%2B/manual/using_dual_abi.html

Thanks for the reply Amadio. I am a bit confused then, why is the ./configure help stating that macOS with GCC is supported?

I need a GCC compiled ROOT because I need to compile a framework which does not compile with clang (and has a hard ROOT dependency). I though it would be easier to go with ROOT/GCC than trying to get the other framework compile with clang (which seems like a much bigger thing).

Dump macOS, install Ubuntu.

BTW. Use “CMake / make” with ROOT 6 (the classical “configure / make” based method is known to be broken, i.e. not supported any more).

Thanks, that solved my problem immediately.

Ah wait no, I forgot to mention that the requirement is running the software on macOS.

Just change “the requirement”. It’s as simple as that.
You can mark this post as the “Solution”. :rofl:

OK, we change the requirement by replacing a whole load of workstations and I don’t know how many laptops in our collaboration and will tell people to install Ubuntu instead.

What a great answer, sounds like a manager’s solution.

People will love to skip through such comments when they face the same problem, so apologise me, I will ignore these from now on.

Create a Singularity or Docker image (with Ubuntu or CentOS inside).

It’s not ROOT that does not support GCC on MacOS. It’s the combination of MacOS+GCC that is very well-known to be problematic. Even if you do manage to build ROOT with GCC by not linking to any external incompatible code (you can try to enable ROOT’s builtins for that, BTW), you will definitely have problems when you move to compile your framework on Mac with GCC. The fact that something compiles with GCC on Linux does not mean it will compile with GCC on MacOS. Maybe if you get both ROOT and GCC via homebrew you can then manage to compile your framework on top of that later, but I’d say that it’s very likely that you’ll run into problems when compiling your framework with GCC. You may also have better luck if you try a more recent version of ROOT than 6.12/06.

Thanks amadio. Currently I got it compiled without the above mentioned modules but you are probably right and I’ll run against a big wall. :grimacing:

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