Library not loaded (OS X)

In short, library is not loaded when from outside its native directory.

The sequence of commands triggering the problem is the following (executed from the ROOT command line):

  1. load my library (.L lib. so)
  2. load and compile my macro (.L macro.C++)
  • When I was working on Linux w/ ROOT,v5, it worked, wheresoever.
  • When now on MAC, w/ ROOT,v6, and that takes place from the native directory of my software (where the library has been compiled and is residing), it also works,
  • When that takes place from any other directory, it does not work, w/ error message (lib = SimpleDetect and macro = ReadDetDat):

Info in TMacOSXSystem::ACLiC: creating shared library /Users/ybedfer/analysis/root.macros/Alberts_plots/
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Users/ybedfer/analysis/root.macros/Alberts_plots/, 9): Library not loaded:
Referenced from: /Users/ybedfer/analysis/root.macros/Alberts_plots/
Reason: image not found
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64

I can add that I had to face a similar problem for loading the library in the first place.

  • Worked on Linux, w/ v5 whersoever.
  • Works on MAC w/ v6 when from the native directory.
  • Does not work from outside the native directory, w/ this time, error message:

Missing FileEntry for SimpleDetect.h
requested to autoload type SimpleDetect

I found the solution on roottalk: have to define a “ROOT_INCLUDE_PATH” environment variable.

Yann Bedfer

Hi Yann,

I understand you fixed the issue with headers with the ROOT_INCLUDE_PATH: is this correct ?
About your library not being in “./”: is the directory where it’s located part of the LD_LIBRARY_PATH ?


Yes. It’s in the LD_LIBRARY_PATH.

As I already said, I did everything so that it’s working under Linux, w/ root,v5. And the LD_LIBRARY_PATH is indeed needed there.

I also have this ``software directory’’ in the “Unix.*.Root.DynamicPath” defined in my "./rootrc’.


Can you pin the effect down in a minimal reproducer?

Hi Yann,

You probably need to add the directory in which the library resides to the LD_LIBRARY_PATH and possibly to the DYLD_LIBRARY_PATH. Alternative you may want to try loading with a full path( .L /…/ )


Hello Philippe,

Yes, indeed, DYLD_LIBRARY_PATH fixes the problem. Thank you very much!!

Whereas loading w/ full path does not change anything (I had already tried by myself cheap things like this one, in fact…)

Thanking you again,