I’ve been struggling with this for quite some time now and I can’t find a solution. Searching for answers, I came across a lot of things about rpath, the way to adapt the CMakeLists.txt file to make it work, etc. It seems that my problem is related to the fact Mac OS do not allow the use of LD_LIBRARY_PATH anymore. And I don’t want to bypass default system settings as it’s often suggested. Looking for solutions on the forums, not only on ROOT forums, I found out that some new instructions need to be added in the CMakeLists.txt file, so I added this:
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
message(STATUS "Darwin specific RPATH configuration")
set(CMAKE_MACOSX_RPATH TRUE)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
list(APPEND CMAKE_BUILD_RPATH ${PROJECT_BINARY_DIR}/lib)
endif()
The output of otool utility can be found here. It seems reasonable to me, but I’m not familiar with rpath.
The only way I can make everything work is to change directory to the one where the macro file is located. Then, I load the library using the relative path, and I run my script. It looks like this:
.L ../lib/libMyLib.so
.L MyMacro.C
test_func()
Ok it works like this, but I’d like to be able loading the library from anywhere, and execute the macro from anywhere as well. For example, if I try this, so from the parent directory:
.L ./lib/libMyLib.so
.L ./scripts/MyMacro.C
and then I have this message:
libMyClasses dictionary payload:5:10: remark: could not acquire lock file for module MyClasses': failed to create unique file
/usr/local/Cellar/root/6.24.06_2/lib/root/MyClasses.pcm.lock-ae721b5d: Permission denied [-Rmodule-build]
#include "/<path to>/inc/Data.h"
^
libMyClasses dictionary payload:5:10: remark: building module 'MyClasses' as '/usr/local/Cellar/root/6.24.06_2/lib/root/MyClasses.pcm' [-Rmodule-build]
error: unable to open output file '/usr/local/Cellar/root/6.24.06_2/lib/root/MyClasses.pcm': 'Permission denied'
libLIVlihoodClasses dictionary payload:5:10: remark: finished building module 'MyClasses' [-Rmodule-build]
libLIVlihoodClasses dictionary payload:5:10: fatal error: could not build module 'MyClasses'
It’s totally normal that there is no permission to write in “/usr/local/Cellar/root/6.24.06_2/lib/root/”, but why root tries to write there at the first place? How can I tell root to write somewhere else?
Not being an expert with cmake or rpath, everything is quite difficult to understand!
Thanks for the help,
Cheers!
ROOT Version: 6.24/06, installed using brew
Platform: Mac OS 11.6.5
Compiler: Apple clang version 13.0.0 (clang-1300.0.29.3)