Error while re-compiling ROOT with Xcode 11

I’m trying to compile ROOT in the following environment and I get the error message while running cmake:

-- Looking for python
CMake Error at cmake/modules/SearchInstalledSoftware.cmake:444 (message):
  Version mismatch between Python interpreter (2.7.10) and libraries
  (2.7.16).
  ROOT cannot work with this configuration.  Please specify only
  PYTHON_EXECUTABLE to CMake with an absolute path to ensure matching
  versions are found.
Call Stack (most recent call first):
  CMakeLists.txt:159 (include)

I didn’t install any special python version. I’ve always simply used the one that comes with the OS.
Moreover, looking at the CMakeFiles/CMakeError.log:

Performing C++ SOURCE FILE Test GLIBCXX_USE_CXX11_ABI failed with the following output:
Change Dir: /Users/dinardo/root_v6.18.04/myBuild/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_b096a/fast 
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_b096a.dir/build.make CMakeFiles/cmTC_b096a.dir/build
Building CXX object CMakeFiles/cmTC_b096a.dir/src.cxx.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++    -std=c++11 -Wc++11-narrowing -Wsign-compare -Wsometimes-uninitialized -Wconditional-uninitialized -Wheader-guard -Warray-bounds -Wcomment -Wtautological-compare -Wstrncat-size -Wloop-analysis -Wbool-conversion -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Qunused-arguments -pthread -stdlib=libc++ -DGLIBCXX_USE_CXX11_ABI -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.14   -std=c++11 -o CMakeFiles/cmTC_b096a.dir/src.cxx.o -c /Users/dinardo/root_v6.18.04/myBuild/CMakeFiles/CMakeTmp/src.cxx
/Users/dinardo/root_v6.18.04/myBuild/CMakeFiles/CMakeTmp/src.cxx:4:4: error: NOCXX11
  #error NOCXX11
   ^
1 error generated.
make[1]: *** [CMakeFiles/cmTC_b096a.dir/src.cxx.o] Error 1
make: *** [cmTC_b096a/fast] Error 2

Source file was:

#include <string>
#if _GLIBCXX_USE_CXX11_ABI == 0
  #error NOCXX11
#endif
int main() {}

Can you please give me some hints?

Many thanks,

  • Mauro.

ROOT Version: 6.18.04
Platform: MAC OS 10.14.6
Compiler: Xcode 11.0


@etejedor Could you look into the python configuration issue?

You can work around the issue with the following patch:

diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake
index ed06b5d3ad..6181407464 100644
--- a/cmake/modules/SearchInstalledSoftware.cmake
+++ b/cmake/modules/SearchInstalledSoftware.cmake
@@ -474,7 +474,7 @@ if(python)
   find_package(PythonLibs ${python_version} REQUIRED)
 
   if(NOT "${PYTHONLIBS_VERSION_STRING}" MATCHES "${PYTHON_VERSION_STRING}")
-    message(FATAL_ERROR "Version mismatch between Python interpreter (${PYTHON_VERSION_STRING})"
+    message(WARNING "Version mismatch between Python interpreter (${PYTHON_VERSION_STRING})"
     " and libraries (${PYTHONLIBS_VERSION_STRING}).\nROOT cannot work with this configuration. "
     "Please specify only PYTHON_EXECUTABLE to CMake with an absolute path to ensure matching versions are found.")
   endif()

That would work on Linux if python was build with enable-shared. Doesn’t fly on Mac. You’ll get an abort, claiming the interpreter was not initialized (b/c you’ll have two interpreter instances).

Somehow, it seemts to works for me on Mac … maybe because the difference is minor (2.7.10 vs 2.7.16). Note: this is a workaround. We obviously need to understand and correct it ‘the right way’ …(@etejedor could you help?)

Hi guys,
many thanks for the patch.
I’m not an expert, so what I did is to copy what you wrote in the file python.patch file and run the command:
patch -p0 < python.patch
I get the error message:

can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake
|index ed06b5d3ad..6181407464 100644
|--- a/cmake/modules/SearchInstalledSoftware.cmake
|+++ b/cmake/modules/SearchInstalledSoftware.cmake
--------------------------
File to patch:

Many thanks.

  • Mauro.

try patch -p1 and/or answer the question with:cmake/modules/SearchInstalledSoftware.cmake
Note you need to be in the top directory of the source repository.

Dear All,
many thanks for your support.
Before seeing the reply from @pcanal I patched the file myself “by hand”.
It works.
Cheers,

  • Mauro.

@amadio any clue of why the CMake error above happens?

You are probably missing the headers for the Python version you are trying to use. I added this version check to ensure the Python interpreter and its library and headers match, so I really do not recommend the “solution” proposed above. If you hit an error due to this check, it’s because something is wrong with the configuration, that is, you are configuring with one Python version, but will link with the libraries for another version. Please inspect the value of ${PYTHON_INCLUDE_DIRS} and ${PYTHON_LIBRARIES} you get after configuration. If you mix different versions of Python compiled with different compilers, the ABI is not guaranteed to be compatible and things may fail at runtime. If you want to use a specific version of Python and setting -DPYTHON_EXECUTABLE=/path/to/python is not enough, you can try to set the two variables above explicitly when running CMake to get a consistent setup.

Dear @amadio,
I didn’t do anything special to my python installation.
I’ve always kept the operating system and Xcode up to date, and I never installed anything “manually”.

  • Mauro.

Can you please paste the equivalent of the lines below for your configuration (i.e., when you run cmake from scratch)?

-- Looking for python
-- Found PythonInterp: /usr/bin/python (found version "3.7.4") 
-- Found PythonLibs: /usr/lib/libpython3.7m.so (found version "3.7.4") 

Dear @amadio,
here they are:

-- Looking for python
-- Found PythonInterp: /usr/bin/python (found version "2.7.10")
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.16")
  • Mauro.

That’s very strange. Can you paste the output of grep ^PYTHON CMakeCache.txt?

Here it is:

PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python
PYTHON_INCLUDE_DIR:PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/python2.7
PYTHON_LIBRARY:FILEPATH=/usr/lib/libpython2.7.dylib
PYTHON_LIBRARY_DEBUG:FILEPATH=PYTHON_LIBRARY_DEBUG-NOTFOUND
PYTHON_EXECUTABLE-ADVANCED:INTERNAL=1
PYTHON_INCLUDE_DIR-ADVANCED:INTERNAL=1
PYTHON_LIBRARY-ADVANCED:INTERNAL=1
PYTHON_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
  • Mauro.

This is likely the problem. You are on 10.14, but using the SDK for 10.15, which has a newer version of Python headers. In this particular case, it might be fine to just ignore the check for the version. But if you can switch to using the SDK for 10.14, that will probably make the configuration problem go away.

It seems that short of reverting to the older version of XCode there is no ‘official’ ways to download the older SDK :frowning: … see (maybe) https://github.com/devernay/xcodelegacy and https://github.com/phracker/MacOSX-SDKs

Doing

cd somewhere
git clone git@github.com:phracker/MacOSX-SDKs.git
sudo mv MacOSX-SDKs/MacOSX10.14.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ 

and then

export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/
cd where_root_build_dir_is
cmake -DPYTHON_INCLUDE_DIR:PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/python2.7 .

seems to work so far

Hi @amadio,
many thanks for figuring this out.
I think Apple made the mess.
Given that Catalina is coming out, their updates are not aligned.
For the time being I’ll stay with the patch.

  • Mauro.

I have submitted https://gitlab.kitware.com/cmake/cmake/issues/19763 Please upvote that if you want to see it fixed.

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