Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dlopen() error image not found

I have software that first loads a .dylib lets call libFirst.dylib using the following command:

void* handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_GLOBAL);

Later on inside a function from the loaded libFirst.dylib I attempt to load another .dylib using the same command but for libSecond.dylib, the loading of this shared library gives me the following warnings in my Xcode console:

error warning: Ignored unknown object module at 0x129310 with type 0x8a8399

dlerror: dlopen(/path/libSecond.dylib, 9): Library not loaded: libFirst.dylib
  Referenced from: /path/libSecond.dylib
  Reason: image not found

What I don't get is that its says libFirst.dylib is not loaded but I am currently inside a function from libFirst.dylib, so how can this be?

All my paths in DYLD_LIBRARY_PATH appear correct too.

Thanks in advance, I have been stuck on this for days.

like image 908
Michael Wildermuth Avatar asked Jul 15 '11 18:07

Michael Wildermuth


1 Answers

I ended up using -install_name to change the install name of all my libraries to @rpath/dylibName.dylib and then in Xcode I set the Runpath Search paths using @loader_path to find all my .dylibs that I was using.

like image 63
Michael Wildermuth Avatar answered Oct 21 '22 03:10

Michael Wildermuth