Rpath setting with cmake for locally installed root conda macos

I am trying to use a library that uses root (proteus). The CmakeLists.txt has the following two lines that are related to root.

find_package(ROOT 6.10 REQUIRED COMPONENTS Hist Tree)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ROOT_CXX_FLAGS}")

….

I have root installed with mamba/conda into the base environment. The cmake finds root without a problem, the compilations also succeeds. But at a run time the program does not find root libraries. It is for some reason looks for them in /usr/lib and /usr/local/lib which specified by @rpath. I can of course can copy the libraries there, but I was wandering if there is a more elegant way to solve the problem.

_ROOT Version:6.26
Platform: macos
Compiler: mac book pro


You need to complain to whoever sets this “rpath” (“proteus” and/or “mamba/conda” maintainers).

BTW. You should be able to use “patchelf --set-rpath” to modify the "RUNPATH" of your shared libraries and executables.

Thank you for the super fast reply!
I have control over proteus. I cloned the library locally. ( I don’t think it is supported by the original author any longer.) But I am not cmake or rpath expert. Is there something I can add to CmakeLists.txt so it adds the root libs location to rpath?

I will try pathelf

Uncle Google → CMake RPATH

By the way, have you tried to use patchelf on macosx? I am having problems installing it…

I use Linux.
Maybe @couet and/or @Axel could help, and/or: ROOT Forum → Search → macOS RPATH

Actually, I’ve just found this:

Unfortunately switching to v6.28 did not help. I installed 6.28 with mamba:

(base) ➜  build git:(master) ✗ which root
/Users/hits/mambaforge/bin/root
(base) ➜  build git:(master) ✗ root --version
ROOT Version: 6.28/00
Built for macosxarm64 on Mar 05 2023, 23:56:00
From @

but libraries still do not have correct rpaths.

dyld[78556]: Library not loaded: '@rpath/libHist.6.28.so'
  Referenced from: '/Users/hits/software/proteus/bin/pt-recon'
  Reason: tried: '/usr/local/lib/libHist.6.28.so' (no such file), '/usr/lib/libHist.6.28.so' (no such file)

here is also an output from otool

(base) ➜  build git:(master) ✗ otool -L ../bin/pt-recon
../bin/pt-recon:
	@rpath/libHist.6.28.so (compatibility version 6.28.0, current version 6.28.0)
	@rpath/libTree.6.28.so (compatibility version 6.28.0, current version 6.28.0)
	@rpath/libMatrix.6.28.so (compatibility version 6.28.0, current version 6.28.0)
	@rpath/libMathCore.6.28.so (compatibility version 6.28.0, current version 6.28.0)
	@rpath/libImt.6.28.so (compatibility version 6.28.0, current version 6.28.0)
	@rpath/libMultiProc.6.28.so (compatibility version 6.28.0, current version 6.28.0)
	@rpath/libNet.6.28.so (compatibility version 6.28.0, current version 6.28.0)
	@rpath/libRIO.6.28.so (compatibility version 6.28.0, current version 6.28.0)
	@rpath/libThread.6.28.so (compatibility version 6.28.0, current version 6.28.0)
	@rpath/libCore.6.28.so (compatibility version 6.28.0, current version 6.28.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1300.36.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)

I tried setting DYDL_LIBRARY_PATH to /Users/hits/mambaforge/lib but that broke other things (for example vim)

For now I think I will copy the needed libraries to /usr/local/lib but if someone (@couet and/or @Axel) have a better idea to try please let me know.

I checked another package with otool, somehow that one did it right:

(base) ➜  HighResAnalysis git:(master) ✗ otool -l ~/software/eudaq-2/bin/euCliConverter |grep -a2 LC_RPATH
compatibility version 1.0.0
Load command 35
          cmd LC_RPATH
      cmdsize 40
         path /Users/hits/mambaforge/lib (offset 12)
--
 datasize 2208
Load command 39
          cmd LC_RPATH
      cmdsize 32
         path @loader_path/../lib (offset 12)
Load command 40
          cmd LC_RPATH
      cmdsize 40
         path @loader_path/../extern/lib (offset 12)

but I get nothing in proteus:

(base) ➜  HighResAnalysis git:(master) ✗ otool -L ~/software/proteus/bin/pt-recon |grep -a2 LC_RPATH
(base) ➜  HighResAnalysis git:(master) ✗ 

So I think I am getting closer …

adding the lines below fixed the problem:

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
	set(PROTEUS_INSTALL_RPATH "@loader_path/../lib;@loader_path/../extern/lib")
else()
	set(PROTEUS_INSTALL_RPATH "\$ORIGIN/../lib:\$ORIGIN/../extern/lib")
endif()
set(CMAKE_SKIP_BUILD_RPATH  FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH ${EUDAQ_INSTALL_RPATH})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

I think the most important was the last one:

set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

the default CMAKE action is to replace rpath on install (when you type make install) with nothing.

More info is on CMAKE RPATH Instructions

Thanks. Is there anything for us to fix on the ROOT side of things?

Perhaps only on the documentation side. Otherwise, everything works.

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