Help Needed RE: Proper Use of CMAKE_INSTALL_PREFIX in Installing ROOT

After successfully building ROOT 6 from source using a script that does effectively the following:

cd
git clone http://root.cern.ch/git/root.git root_src
mkdir root_build
cd root_build
unset ROOTSYS
cmake -Dall="ON" -Dsoversion="ON" -Dqtgsi="OFF" ../root_src >> cmake.out.txt 2>&1
cmake --build . -- -j4 >> cmake.out.txt 2>&1

I am then trying to use the CMake commands outlined on the “Building ROOT” page to install it in /usr/local/root/
However, when I do

cd /usr/local/
mkdir root
cd ~/root_build/
sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/root/

I get

CMake Error: The source directory "/home/mcf/root_build" does not appear to contain CMakeLists.txt.

and the only CMakeLists.txt in the build dir is in the tutorials sub dir, which shouldn’t be it.

If I do

sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/root -P cmake_install.cmake

then everything gets to /usr/local/root/ just fine

$ cd /usr/local/root/
$ ls -d */
aclocal//  config//  fonts//  include//  man//     tmva//
bin//      emacs//   geom//   lib//      README//  tutorials//
cmake//    etc//     icons//  macros//   test//

and I can do

but if I try and run a script with RooStats code in it I get things like

cling::DynamicLibraryManager::loadLibrary(): libpng16.so.16: cannot open shared object file: No such file or directory

and a seg fault. Yet if I source root from the build directory

source ~/root_build/bin/thisroot.sh

and try to run the RooStats script everything works fine so I have obviously done something wrong in the installation.

I realize that this is probably something very trivial and that in the past [url=https://root-forum.cern.ch/t/locate-like-command/65/1 and Axel have offered some comments[/url] about installation using CMake, however I haven’t really understood. I am finding proper installation using CMake style commands confusing (though I admittedly need to go RTFM on CMake), and any pointers here could be useful.

When you did:sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/root/you either should put dot (.) or the location of the source directory.

Cheers,
Philippe.

Once you have build successfully the command

sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/root -P cmake_install.cmake

should be sufficient. You do not need to reconfigure and rebuild just to change the installation prefix, which is by default /usr/local.
Concerning the missing library (libpng16.so.16) when run from the installation area we will need to debug it. Are you running in same node that you did the build? If the library in the build directory ( ~/root_build/lib ) ?

Hi Mato,

I apologize, but when you ask if

I don’t think I understand what you’re asking. As to if the library in question is in the build directory, the answer is no.

$ cd ~/root_build/lib
$ find . -iname "libpng16.so.16"

returns nothing.

However, it is found in anaconda

$ cd
$ find . -iname "libpng16.so.16"
./anaconda3/lib/libpng16.so.16
./anaconda3/pkgs/libpng-1.6.22-0/lib/libpng16.so.16

[Also, sorry for the delay in seeing your response. I seemed to have missed the notification email.]

Take a look at:

for a workaround.

Many thanks, ferhue. After looking over [url=https://root-forum.cern.ch/t/root-v6-06-08-broken-segmentation-when-calling-tbrowser/22194/4 solution[/url] I found that simply copying the library works. So

$ find $HOME -iname libpng16.so.16 -print -quit 2>/dev/null
/home/mcf/anaconda3/lib/libpng16.so.16
$ sudo cp $HOME/anaconda3/lib/libpng16.so.16 $ROOTSYS/lib/
$ source $ROOTSYS/bin/thisroot.sh

allows me to run the offending code of the original post just fine. This seems to be congruent with other libpng16.so.16 issues out in the wild.

However, ideally as this is all going in an install script I would like to be able to do this all from CMake, and not have to do manual finding and copying. Is there a CMake standard variable for this at all (it doesn’t seem like it)?

Hi,
The source of the problem is that the CMake of ROOT is finding the library libpng16.so.16 (probably because the program ‘libpng-config’ is found and points to the library), but this library is not usable from the location it is. If you add /…/anaconda3/lib into the DYLD_LIBRARY_PATH would have also worked. In my opinion, is a problem of the way anaconda does the installation of libpng16.

Pere