ROOT in GEANT4 libCore.so not found, CMakeCache showing wrong directory?

Hi ROOTers.
I have a Geant4-10.02 application which I’m linking in ROOT 6.04.14. On one computer this is working perfectly, but when trying to replicate this setup on another computer, I’m encountering problems.

On the problematic machine, during application build I receive a number of shadow declarations where variables are overlapping between ROOT source files and GEANT4’s internal CLHEP source files. Eventually the build crashes with:

Notably the location ‘/usr/local’ here is wrong; this should be pointing to $ROOTSYS/lib/libCore.so (specifically /home/marc/LinuxSystemFiles/ROOT/root-6.04.14/build/lib/libCore.so)

Looking through my CMakeCache.txt, I have

//The directory containing a CMake configuration file for ROOT. ROOT_DIR:PATH=/home/marc/LinuxSystemFiles/ROOT/root-6.04.14/buildwhich is correctly pointing to ROOTConfig.cmake, but surrounding this line I also have many lines of the form:

//Path to a library. ROOT_Core_LIBRARY:FILEPATH=/usr/local/lib/libCore.sowhich point to incorrect locations.

Now, although this seems to (me to) be the source of the problem, I’ve compared CMakeLists.txt, ROOTConfig.cmake and CmakeCache.txt files from the working and not-working machines, and they are all identical. In fact editing the CMakeCache.txt to the correct locations doesn’t change anything (except the locations in the build error). I can only conclude the CMakeCache.txt oddities are a red herring… :question: But then, why is my application failing to find libCore.so?? :neutral_face:

ROOT is included in my CMakeLists.txt very minimally as:

...
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
find_package(ROOT REQUIRED)
...

include(${ROOT_USE_FILE})

...
target_link_libraries(wchsandbox ${ROOT_LIBRARIES})

which is based on https://root.cern.ch/how/integrate-root-my-project-cmake and https://root.cern.ch/faq/can-i-integrate-root-my-cmake-build.

HI,

What is the value of ${ROOT_LIBRARIES} just before the execution of target_link_libraries?

Philippe.

[quote=“pcanal”]HI,

What is the value of ${ROOT_LIBRARIES} just before the execution of target_link_libraries?

Philippe.[/quote]

Hi Phillipe. Thanks for the help. The requested variable is:

Hi,

The simplest solution might be to un-install ROOT from /usr/local …

Cheers,
Philippe.

[quote=“pcanal”]Hi,

The simplest solution might be to un-install ROOT from /usr/local …

Cheers,
Philippe.[/quote]

ROOT is not located in /usr/local. I have no idea where it’s obtaining that path from.

This is very strange.

  • Are you sure there is no another ROOT installation in /usr/local/lib?
  • Did you run /home/marc/LinuxSystemFiles/ROOT/root-6.04.14/build/bin/thisroot.sh before configuring your project?
  • Did you start with a clean CMakeCache.txt? or a clean build area?
  • If you answer yes to all of them, then we need to debug it. For this, please issue the configure command with --trace and attach the obtained output
cmake --trace  <options> <source> 

[quote=“mato”]This is very strange.

  • Are you sure there is no another ROOT installation in /usr/local/lib?
  • Did you run /home/marc/LinuxSystemFiles/ROOT/root-6.04.14/build/bin/thisroot.sh before configuring your project?
  • Did you start with a clean CMakeCache.txt? or a clean build area?
  • If you answer yes to all of them, then we need to debug it. For this, please issue the configure command with --trace and attach the obtained output

cmake --trace <options> <source> [/quote]
:exclamation:
Well, that fixed it. It hadn’t occurred to me to remove CMakeCache.txt before. :blush: (all others were ‘yes’) After I did that, it regenerated the CMakeCache file with the correct paths and built without a problem.

Thanks mato, and Philippe. :slight_smile:

There are a couple of things I’m still puzzled about - if i manually edit CMakeCache.txt now, to put the /usr/local back in, I get the exact errors I had before. But manually correcting it back makes it work again. Now, as I posted - I had tried manually correcting CMakeCache.txt, and it hadn’t worked. Why it does work now?

Secondly, my other system still has a CMakeCache.txt file that has the wrong paths in, and still builds perfectly fine…!

Mystery 2 solved - the system I was copying from was my first root install, and frankly it was a mess (much installing/reinstalling/things not being where they should be). On that machine a copy of libCore.so has ended up in /usr/local/lib. Quite why CMakeCache.txt is pointing to it (rather than the proper version in $ROOTSYS) I don’t know, but… that explains why it works at least.

You should never edit by hand CMakeCache.txt. This is the cache for CMake and is used to remember many parameters and already located libraries and paths.

It would have only been a test to see whether those were the origin of the errors, not a permanent solution. The file itself says in it’s header # You can edit this file to change values found and used by cmake.