PyROOT LoadMacro problem with shared library

Hello,

I have a python script that loads a macro written in C++ that I would rather not translate into python. I have the macro in a particular directory “/path/to/Macro/Macro.C”. I load the macro into python with

import ROOT
from ROOT import gROOT
gROOT.LoadMacro("/path/to/Macro/Macro.C+")

I have moved the python script into /usr/local/bin (maybe this is where the issue is) so that I can run it from any directory. When I execute it for the first time it runs fine and the gROOT.LoadMacro() creates file *.pcm, *.so and *.d in the same directory as the Macro. However if I change directories and run the python script again it fails with:

cling::DynamicLibraryManager::loadLibrary(): dlopen(/Users/Code/Macro_C.so, 9): Library not loaded: @rpath/libHist.so

If I delete all the extra files and run again it runs fine. I am just not sure how to be able to keep the macro in a certain directory and run the script how I want to without having to delete the shared library each time. I have tried moving the macro the the root/macros directory and that did not change the behavior.

Thank you,


_ROOT Version:6.16.00
_Platform:OSX 10.14.5
Compiler: Not Provided


Try:

gROOT.LoadMacro("/path/to/Macro/Macro.C++")

Thank you for the suggestion, it does seem to work! What does the extra ‘+’ do exactly? It causes the shared library to be remade each time it is run but maybe I was wrong thinking that could be avoided. With this I don’t have explicitly delete the library at the end of the code.

Thank you

The additional + resquest the rebuilding of the library whether it exist before or not.

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