Error when building root 6.26/06 on MacOS Monterey 12.5


ROOT Version: 6.26/06 (attempted installation)
Platform: MacOS Monterey 12.5
Compiler: clang-1316.0.21.2.5


I tried to build ROOT from source on my device and received the following error output:

[ 75%] Generating G__Core.cxx, ../lib/Core.pcm
While building module 'Core':
While building module 'std' imported from input_line_1:1:
While building module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctype.h:38:
In file included from <module-includes>:1421:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/ncurses.h:141:
/opt/local/include/unctrl.h:61:38: error: cannot initialize a variable of type 'char *' with an lvalue of type 'char *(chtype)' (aka 'char *(unsigned int)')
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
                                     ^               ~~~~~~
/opt/local/include/unctrl.h:61:61: error: expected ';' after top level declarator
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
                                                            ^
While building module 'Core':
While building module 'std' imported from input_line_1:1:
In file included from <module-includes>:2:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctype.h:38:15: fatal error: could not build module 'Darwin'
#include_next <ctype.h>
 ~~~~~~~~~~~~~^
input_line_1:1:10: fatal error: could not build module 'std'
#include <new>
 ~~~~~~~~^
Warning in cling::IncrementalParser::CheckABICompatibility():
  Failed to extract C++ standard library version.
Warning in cling::IncrementalParser::CheckABICompatibility():
  Possible C++ standard library mismatch, compiled with _LIBCPP_ABI_VERSION '1'
  Extraction of runtime standard library version was: ''
While building module 'Core':
While building module 'Cling_Runtime' imported from input_line_2:1:
While building module 'Cling_Runtime_Extra' imported from /Users/user/Documents/Software/root-6.26.06-build/etc/cling/Interpreter/RuntimeUniverse.h:27:
In file included from <module-includes>:1:
/Users/user/Documents/Software/root-6.26.06-build/etc/cling/Interpreter/DynamicExprInfo.h:13:10: fatal error: could not build module 'std'
#include <string>
 ~~~~~~~~^
/Users/user/Documents/Software/root-6.26.06-build/etc/cling/Interpreter/RuntimeUniverse.h:27:10: fatal error: could not build module 'Cling_Runtime_Extra'
#include "cling/Interpreter/Visibility.h"
 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
While building module 'Core':
While building module '_Builtin_intrinsics':
In file included from <module-includes>:2:
In file included from /Users/user/Documents/Software/root-6.26.06-build/etc/cling/lib/clang/9.0.1/include/arm_acle.h:17:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdint.h:123:15: fatal error: could not build module 'Darwin'
#include_next <stdint.h>
 ~~~~~~~~~~~~~^
While building module 'Core':
<<< cling interactive line includer >>>: fatal error: could not build module '_Builtin_intrinsics'
Error: Module '_Builtin_intrinsics' failed to load.
While building module 'Core':
While building module 'ROOT_Rtypes' imported from /Users/user/Documents/Software/root-6.26.06-build/include/Rtypes.h:23:
In file included from <module-includes>:1:
In file included from /Users/user/Documents/Software/root-6.26.06-build/include/RtypesCore.h:23:
/Users/user/Documents/Software/root-6.26.06-build/include/ROOT/RConfig.hxx:279:13: fatal error: could not build module 'Darwin'
#   include <AvailabilityMacros.h>
    ~~~~~~~~^
While building module 'Core':
While building module 'ROOT_Rtypes' imported from /Users/user/Documents/Software/root-6.26.06-build/include/Rtypes.h:23:
While building module 'ROOT_Config' imported from /Users/user/Documents/Software/root-6.26.06-build/include/RtypesCore.h:25:
In file included from <module-includes>:1:
In file included from /Users/user/Documents/Software/root-6.26.06-build/include/RConfig.h:23:
/Users/user/Documents/Software/root-6.26.06-build/include/ROOT/RConfig.hxx:279:13: fatal error: could not build module 'Darwin'
#   include <AvailabilityMacros.h>
    ~~~~~~~~^
While building module 'Core':
While building module 'ROOT_Foundation_C' imported from /Users/user/Documents/Software/root-6.26.06-build/include/Rtypes.h:29:
In file included from <module-includes>:1:
In file included from /Users/user/Documents/Software/root-6.26.06-build/include/ThreadLocalStorage.h:57:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stddef.h:45:15: fatal error: could not build module 'Darwin'
#include_next <stddef.h>
 ~~~~~~~~~~~~~^
While building module 'Core':
While building module 'ROOT_Foundation_Stage1_NoRTTI' imported from /Users/user/Documents/Software/root-6.26.06-build/include/Rtypes.h:195:
In file included from <module-includes>:2:
/Users/user/Documents/Software/root-6.26.06-build/include/ROOT/RStringView.hxx:25:10: fatal error: could not build module 'std'
#include <string_view>
 ~~~~~~~~^
Error: Error loading the default rootcling header files.
make[2]: *** [core/G__Core.cxx] Error 1
make[1]: *** [core/CMakeFiles/G__Core.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 75%] Built target Cling
make: *** [all] Error 2

My system and xcode are all up to date, and I use the usual cmake commands to build and install it. Judging by the error output, it seems there is an issue with the C++ standard, but I tried already to set it to 17 via the CXX_STANDARD flag. I also removed all build files before attempting this. Does anyone know where this error may come from? Any help would be appreciated, thanks a lot in advance.

Hi @eska ,

thank you for your report. I have never seen this error. It mentions MacOSX12.3.sdk but you mentioned you are on 12.5, could there be a compiler toolchain/MacOS version mismatch there?

If not, maybe @vvassilev or @Axel have an idea about what’s going wrong with the std module.

As a side note, usually you don’t need to build ROOT from source but you can grab one of our pre-compiled binaries, see Installing ROOT - ROOT .

Cheers,
Enrico

Hi Enrico,

Thanks a lot for the fast reply! I see what you mean. But checking on the xcode support page, it seems that this is the maximum SDK version I can have with the latest xcode version.

I actually have been using a precompiled version on my Mac so far, but lately I’ve run into issues that I couldn’t solve. The most pressing one was that I couldn’t use the TSpectrum module, so I was hoping that building from scratch would allow me to explicitly enforce that spectrum is included in the root libraries.

Apologies for the late reply: this is caused by Homebrew’s /opt/local/include/unctrl.h being incompatible with Xcode. The only work-around I am aware of is

sudo mv /opt/local/include /opt/local/include-homebrew-out-of-the-way`

Copying the terminal output and what I used for CMake here:

The version that I have downloaded that I use right now is “macOS 12.4 arm64 Xcode 13” from the 6.26/06 release (I believe arm64 is the right choice since I have an M1 CPU). It does seem like TSpectrum somehow exists in my ROOT installation, since I can run macros that use TSpectrum, but when I try to use compiled code, I get the following error message:

Undefined symbols for architecture arm64:
  "TSpectrum::TSpectrum(int, double)", referenced from:
      _main in mainfile.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [mainfile] Error 1
make[1]: *** [CMakeFiles/mainfile.dir/all] Error 2
make: *** [all] Error 2

The ROOT-relevant lines in my CMakeList.txt file:

set(CMAKE_MODULE_PATH $ENV{ROOTSYS}/cmake/ ${CMAKE_MODULE_PATH})
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})

find_package(ROOT REQUIRED)
include_directories($ENV{ROOTSYS}/include/root /Users/user/Documents/Software/boost_1_79_0)
message(STATUS "ROOT will be used: $ENV{ROOTSYS}")

SET(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})

target_link_libraries(mainfile ${ROOT_LIBRARIES} Spectrum)

which now leads to the following terminal output:

Consolidate compiler generated dependencies of target mainfile
[ 33%] Linking CXX executable mainfile
ld: library not found for -lSpectrum
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [mainfile] Error 1
make[1]: *** [CMakeFiles/mainfile.dir/all] Error 2
make: *** [all] Error 2

Also, before I compile, I have a bash script to set the environment with the following lines:

source /opt/local/libexec/root6/bin/thisroot.sh
PATH=/opt/local/libexec/root6/include/root:${PATH}
LD_LIBRARY_PATH=/opt/local/libexec/root6/lib/root:${LD_LIBRARY_PATH}

The libSpectrum related entries in /opt/local/libexec/root6/lib/root are:

/opt/local/libexec/root6/lib/root/libSpectrum.6.26.04.so	
/opt/local/libexec/root6/lib/root/libSpectrumPainter.6.26.04.so	
/opt/local/libexec/root6/lib/root/libSpectrumPainter_rdict.pcm
/opt/local/libexec/root6/lib/root/libSpectrum.6.26.so		
/opt/local/libexec/root6/lib/root/libSpectrumPainter.6.26.so	
/opt/local/libexec/root6/lib/root/libSpectrum_rdict.pcm
/opt/local/libexec/root6/lib/root/libSpectrum.rootmap		
/opt/local/libexec/root6/lib/root/libSpectrumPainter.rootmap
/opt/local/libexec/root6/lib/root/libSpectrum.so		
/opt/local/libexec/root6/lib/root/libSpectrumPainter.so

If you need more info, please let me know!

what is the failing link line? It seems to be missing -L /opt/local/libexec/root6/lib/root

(Sorry for the reupload) When I use the verbose, I get the following:

[ 33%] Linking CXX executable mainfile
/Applications/CMake.app/Contents/bin/cmake -E cmake_link_script CMakeFiles/mainfile.dir/link.txt --verbose=TRUE
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/mainfile.dir/mainfile.cpp.o CMakeFiles/mainfile.dir/src/ConfigFileParser.cpp.o -o mainfile  -Wl,-rpath,/opt/local/libexec/root6/lib/root /opt/local/libexec/root6/lib/root/libCore.so /opt/local/libexec/root6/lib/root/libImt.so /opt/local/libexec/root6/lib/root/libRIO.so /opt/local/libexec/root6/lib/root/libNet.so /opt/local/libexec/root6/lib/root/libHist.so /opt/local/libexec/root6/lib/root/libGraf.so /opt/local/libexec/root6/lib/root/libGraf3d.so /opt/local/libexec/root6/lib/root/libGpad.so /opt/local/libexec/root6/lib/root/libROOTDataFrame.so /opt/local/libexec/root6/lib/root/libTree.so /opt/local/libexec/root6/lib/root/libTreePlayer.so /opt/local/libexec/root6/lib/root/libRint.so /opt/local/libexec/root6/lib/root/libPostscript.so /opt/local/libexec/root6/lib/root/libMatrix.so /opt/local/libexec/root6/lib/root/libPhysics.so /opt/local/libexec/root6/lib/root/libMathCore.so /opt/local/libexec/root6/lib/root/libThread.so /opt/local/libexec/root6/lib/root/libMultiProc.so /opt/local/libexec/root6/lib/root/libROOTVecOps.so -lSpectrum 
ld: library not found for -lSpectrum
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [mainfile] Error 1

What happens if you use:

target_link_libraries(mainfile ${ROOT_LIBRARIES} ROOT::Spectrum)

?

Fantastic, this did it!! Thanks a lot!