Installing root6 in MacOS

Hi everyone, I had been using Root for a while on macOS which I built around January this year following the exact instructions provided here: https://root.cern.ch/building-root. I installed the prerequisites using Homebrew. However, I had to change my laptop and I cannot do it anymore following the same instructions. Here is what I did:

  1. Dumped a list of the existing Homebrew packages on the previous laptop in a file
  2. Installed the same packages from the file on the new laptop
  3. Tried to build Root the same way

Here is what the error says:


[ 20%] Linking Fortran executable ../bin/g2root
Undefined symbols for architecture x86_64:
  "__gfortran_compare_string", referenced from:
      _map_found_ in g2root.f.o
      _MAIN__ in g2root.f.o
      _hnmadr_ in libminicern.a(hbook.f.o)
      _hpath_ in libminicern.a(hbook.f.o)
      _hntvar3_ in libminicern.a(hbook.f.o)
      _hropen_ in libminicern.a(hbook.f.o)
      _hldir_ in libminicern.a(hbook.f.o)
      ...
  "__gfortran_concat_string", referenced from:
      _ptname_ in g2root.f.o
      _map_found_ in g2root.f.o
      _volume_ in g2root.f.o
      _node_ in g2root.f.o
      _toroot_ in g2root.f.o
      _MAIN__ in g2root.f.o
      _hpaff_ in libminicern.a(hbook.f.o)
      ...
  "__gfortran_getarg_i4", referenced from:
      _MAIN__ in g2root.f.o
  "__gfortran_iargc", referenced from:
      _MAIN__ in g2root.f.o
  "__gfortran_pow_i4_i4", referenced from:
      _hmachi_ in libminicern.a(hbook.f.o)
  "__gfortran_set_args", referenced from:
      _main in g2root.f.o
  "__gfortran_set_options", referenced from:
      _main in g2root.f.o
  "__gfortran_st_close", referenced from:
      _toroot_ in g2root.f.o
      _create_map_ in g2root.f.o
      _hropen_ in libminicern.a(hbook.f.o)
      _rzopen_ in libminicern.a(zebra.f.o)
  "__gfortran_st_inquire", referenced from:
      _rzopen_ in libminicern.a(zebra.f.o)
  "__gfortran_st_open", referenced from:
      _toroot_ in g2root.f.o
      _create_map_ in g2root.f.o
      _rzopen_ in libminicern.a(zebra.f.o)
  "__gfortran_st_read", referenced from:
      _toreal_ in g2root.f.o
      _create_map_ in g2root.f.o
      _MAIN__ in g2root.f.o
      _rziodo_ in libminicern.a(zebra.f.o)
      _rzopen_ in libminicern.a(zebra.f.o)
  "__gfortran_st_read_done", referenced from:
      _toreal_ in g2root.f.o
      _create_map_ in g2root.f.o
      _MAIN__ in g2root.f.o
      _rziodo_ in libminicern.a(zebra.f.o)
      _rzopen_ in libminicern.a(zebra.f.o)
  "__gfortran_st_write", referenced from:
      _realname_ in g2root.f.o
      _ptname_ in g2root.f.o
      _toint_ in g2root.f.o
      _markdiv_ in g2root.f.o
      _toreal_ in g2root.f.o
      _volume_ in g2root.f.o
      _node_ in g2root.f.o
      ...
  "__gfortran_st_write_done", referenced from:
      _realname_ in g2root.f.o
      _ptname_ in g2root.f.o
      _toint_ in g2root.f.o
      _markdiv_ in g2root.f.o
      _toreal_ in g2root.f.o
      _volume_ in g2root.f.o
      _node_ in g2root.f.o
      ...
  "__gfortran_string_index", referenced from:
      _map_found_ in g2root.f.o
      _toroot_ in g2root.f.o
      _create_map_ in g2root.f.o
      _MAIN__ in g2root.f.o
      _uoptc_ in libminicern.a(kernlib.f.o)
      _cfopen_ in libminicern.a(kernlib.f.o)
      _hrfile_ in libminicern.a(hbook.f.o)
      ...
  "__gfortran_string_len_trim", referenced from:
      _realname_ in g2root.f.o
      _ptname_ in g2root.f.o
      _toint_ in g2root.f.o
      _toreal_ in g2root.f.o
      _toreal_old_ in g2root.f.o
      _cfopen_ in libminicern.a(kernlib.f.o)
      _cfstat_ in libminicern.a(kernlib.f.o)
      ...
  "__gfortran_transfer_array", referenced from:
      _rziodo_ in libminicern.a(zebra.f.o)
  "__gfortran_transfer_array_write", referenced from:
      _rziodo_ in libminicern.a(zebra.f.o)
      _mzlink_ in libminicern.a(zebra.f.o)
  "__gfortran_transfer_character", referenced from:
      _create_map_ in g2root.f.o
  "__gfortran_transfer_character_write", referenced from:
      _realname_ in g2root.f.o
      _ptname_ in g2root.f.o
      _markdiv_ in g2root.f.o
      _toreal_ in g2root.f.o
      _volume_ in g2root.f.o
      _node_ in g2root.f.o
      _toroot_ in g2root.f.o
      ...
  "__gfortran_transfer_integer", referenced from:
      _MAIN__ in g2root.f.o
      _rzopen_ in libminicern.a(zebra.f.o)
  "__gfortran_transfer_integer_write", referenced from:
      _toint_ in g2root.f.o
      _markdiv_ in g2root.f.o
      _node_ in g2root.f.o
      _toroot_ in g2root.f.o
      _g2rin_ in g2root.f.o
      _create_map_ in g2root.f.o
      _hldirt_ in libminicern.a(hbook.f.o)
      ...
  "__gfortran_transfer_real", referenced from:
      _toreal_ in g2root.f.o
  "__gfortran_transfer_real_write", referenced from:
      _toreal_ in g2root.f.o
      _toroot_ in g2root.f.o
      _toreal_old_ in g2root.f.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [bin/g2root] Error 1
make[1]: *** [main/CMakeFiles/g2root.dir/all] Error 2
make: *** [all] Error 2
make: INTERNAL: Exiting with 21 jobserver tokens available; should be 20!

The command
$ gfortran -v

returns the following:

Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/6.3.0_1/libexec/gcc/x86_64-apple-darwin16.3.0/6.3.0/lto-wrapper
Target: x86_64-apple-darwin16.3.0
Configured with: ../configure --build=x86_64-apple-darwin16.3.0 --prefix=/usr/local/Cellar/gcc/6.3.0_1 --libdir=/usr/local/Cellar/gcc/6.3.0_1/lib/gcc/6 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-6 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --with-build-config=bootstrap-debug --disable-werror --with-pkgversion='Homebrew GCC 6.3.0_1' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 6.3.0 (Homebrew GCC 6.3.0_1)

How can I install it/what is the problem?

Thank you.

Maybe @mato could have a look?

David Abdurachmanov suggested:

Some suggestions would be:
(1) Add -DCMAKE_VERBOSE_MAKEFILE=TRUE
Then provide the actual command used for linking: [ 20%] Linking Fortran executable …/bin/g2root
(2) Try adding -DCMAKE_Fortran_COMPILER=gfortran (or even setting a full path).
(3) Use -G Ninja to avoid building Fortran targets (for now).

If you don’t need any of the binaries depending on fortran, a simple -Dfortran=Off might help, too.

Axel.

1 Like

Thank you @Axel for your suggestions. I tried to build it with -Dfortran=Off but this time it gave me an error when linking to a CXX object. So I gave up on cmake and tried building it the old way as instructed here: https://root.cern.ch/build-root-old-method. Now, the command make -j4 returned some error saying it expected some root-related .so files in /usr/local/lib/root directory but could not find them. So, I found those files in the root build directory and symlinked there. That solved the problem.

As for your suggestions, I have no idea how to do (1) or (2), need elaboration. (3) might work, but again, I have no idea about what I have to sacrifice for that.

Well, solved is solved, right? :slight_smile: I’ll leave it to @mato to follow up on this should he be interested in finding out why this goes wrong fro CMake. (But I believe we have had more reports, so this will most likely be tackled.)

On your original problem the issue could be that the gfortran was not properly installed or transferred from our previous laptop. The missing symbols are part of the libgfortran.so library that gfortran should be able to link.
With the option -Dfortran=OFF all the fortran components or ROOT are disabled therefore the problem is avoided.
I would be interested what didn’t work when you tried Dfortran=OFF.

@Axel I agree. Solved is solved.

@mato I didn’t “transfer” gfortran, homebrew dumps a “list” of packages in a text file. It doesn’t contain the packages themselves but only the names sorted dependency-wise. It then downloads the packages off the internet and installs them according to the list. So I don’t think gfortran was a problem. I remember trying to find it out __gfortran_compare_string using grep in the gfortran installation folder and you’re right- it was there in libgfortran.so. And I didn’t set -Dfortran=Off when building it the configure-make way. It linked to /bin/g2root successfully without an issue. And I would have mentioned particulars of the subsequent problems but I already closed that terminal window to enable the effects of the line I added in .bash_profile. If you ask me, I’ll try to reproduce it.

Hi everyone,

I have experienced the same error (the gfortran problem output reported in the first mail) when trying to install ROOT root-6.08.06 in macOS Sierra 10.12.4 with XCode 8.3 (8E162). The first time the problem appeared I was using gfortran from Brew (gcc version 6.3.0_1). I did remove this gcc Brew installation and recompile using the last version from the gnu gcc 6.3.0 source. Now I have:

$ gfortran -v
Usando especificaciones internas.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gcc-6.3.0/libexec/gcc/x86_64-apple-darwin16.5.0/6.3.0/lto-wrapper
Objetivo: x86_64-apple-darwin16.5.0
Configurado con: ../configure --prefix=/usr/local/gcc-6.3.0 --enable-checking=release --with-gmp=/usr/local/Cellar/gmp/ --with-mpfr=/usr/local/Cellar/mpfr/ --with-mpc=/usr/local/Cellar/libmpc/ --enable-languages=c,c++,fortran --with-isl=/usr/local/Cellar/isl/ --program-suffix=-6.3.0
Modelo de hilos: posix
gcc versiĂłn 6.3.0 (GCC)

But the error remained the same.
I was able to compile ROOT using the Dfortran=OFF, though.

Please, let me know if you need more information on the errors.

Thanks for the support,

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