Integrating ROOT with Cmake, undefined references

Hi all,
I have been struggling a bit lately with trying to build applications using geant4 and ROOT in various institutional environments, and it’s made it evident that I don’t really know what’s happening under the hood of the build. I would appreciate any tips anyone has on where ROOT/CMake are finding various things when linking applications.
For example, right now I’m trying to build an application on a Fermilab virtual machine. Before starting, I setup cmake and my desired ROOT version:

source /grid/fermiapp/products/common/etc/setup export PRODUCTS=${PRODUCTS}:/grid/fermiapp/products/larsoft setup -f Linux64bit+2.6-2.12 -q debug:e9:nu root v6_04_06 setup cmake
Then I have a CMakeLists.txt that uses:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} /grid/fermiapp/products/larsoft/root/v6_04_06/source/root-6.04.06/etc/cmake) find_package(ROOT MODULE REQUIRED Cling TreePlayer) include(${ROOT_USE_FILE}) message(STATUS "Environmental ROOTSYS is $ENV{ROOTSYS}") message(STATUS "found root at: ${ROOT_USE_FILE}") message(STATUS "ROOT_LIBRARIES=${ROOT_LIBRARIES}") target_link_libraries(wchsandbox ${ROOT_LIBRARIES})

However, this ends up returning the following:

-- Environmental ROOTSYS is /grid/fermiapp/products/larsoft/root/v6_04_06/Linux64bit+2.6-2.12-e9-nu-debug -- found root at: /grid/fermiapp/products/larsoft/root/v6_04_06/source/root-6.04.06/etc/cmake/RootUseFile.cmake -- ROOT_LIBRARIES=/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libCore.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libCint.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libRIO.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libNet.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libHist.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libGraf.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libGraf3d.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libGpad.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libTree.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libRint.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libPostscript.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libMatrix.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libPhysics.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libMathCore.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libThread.so;/grid/fermiapp/products/larsoft/root/v6_04_06/Linux64bit+2.6-2.12-e9-nu-debug/lib/libCling.so;/grid/fermiapp/products/genie/externals/root/v5_34_25a/Linux64bit+2.6-2.12-e7-nu-debug/lib/libTreePlayer.so
ROOTSYS - OK,
ROOT_USE_FILE - OK
ROOT_LIBRARIES - … somehow cmake has instead dug up an old Root 5.34 version from the depths of obscurity?! #-o
Everything I can find in FindROOT.cmake and RootUseFile.cmake reference ROOTSYS, which is correctly pointing to the v6 folder… where is it getting this? And more importantly, how do I make it use the ROOT version I’m specifying?

Thanks in advance again folks,
Marcus

GENIE is not a part of ROOT.
You need a version of GENIE which was compiled with your ROOT version, or remove all references to GENIE from your setup.

[quote=“Pepe Le Pew”]GENIE is not a part of ROOT.
You need a version of GENIE which was compiled with your ROOT version, or remove all references to GENIE from your setup.[/quote]
I’m aware genie isn’t part of ROOT. I’m not using genie. I don’t know why those paths were included.

Maybe your LArSoft setup contains GENIE?

The LArSoft products directory also contains some 20 different genie installs, but I don’t set any of them up. The LArSoft products directory is used for the Geant4 install. This is setup using the line:

setup geant4 v4_10_1_p02a -q e9:debug:qt

which is done before

setup -f Linux64bit+2.6-2.12 -q debug:e9:nu root v6_04_06

That was the only line I didn’t mention when describing my setup process, for brevity (perhaps a bad idea). The geant4 setup call defines the following ROOT environmental variables:

QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb XERCESCROOT=/grid/fermiapp/products/larsoft/xerces_c/v3_1_2/Linux64bit+2.6-2.12-e9-debug
neither of which seem to point to anything regarding a ROOT 5.34 install.

Execute something like: set | grep -i genie # for bash or [t]csh export | grep -i genie # for bash setenv | grep -i genie # for [t]csh and then repeat these commands after every “source …” and “setup …” and you should be able to find the one that you need to fix.

[quote=“Pepe Le Pew”]Execute something like: set | grep -i genie # for bash or [t]csh export | grep -i genie # for bash setenv | grep -i genie # for [t]csh and then repeat these commands after every “source …” and “setup …” and you should be able to find the one that you need to fix.[/quote]
These both return nothing after each step, and still nothing once all have been run.

I’m afraid you need to talk to people who maintain your “LArSoft” distribution and/or “/grid/fermiapp/products”.

OK, I’ll do that. Thanks for the support Pepe. :slight_smile:

Hi Marcus, If ROOT is built with CMake you should not be using the module FindROOT.cmake in $ROOTSYS/etc/cmake, instead you should be using the module ROOTConfig.cmake. Next major release of ROOT will have FindROOT.cmake removed from the installation. To locate ROOTConfig.cmake is sufficient to add in CMAKE_PREFIX_PATH the installation of ROOT. BTW, this is automatic if you run $ROOTSYS/bin/thisroot.sh to set the ROOT environment. So, in conclusion you just need to remove the line

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} /grid/fermiapp/products/larsoft/root/v6_04_06/source/root-6.04.06/etc/cmake)