OS X Yosemite : Runtime path error



OS X Yosemite complains about the embedded path in the libKrakatoaSR.dylib

$ /Users/nicholas/temp/kk/bin/example03
dyld: Library not loaded: /Users/cwiebe/Development/KrakatoaProject/KrakatoaSR/sharedlib/libKrakatoaSR.dylib
Referenced from: /Users/nicholas/temp/kk/bin/example03
Reason: image not found
Trace/BPT trap: 5

$ otool -L /Users/nicholas/temp/kk/bin/example03
/Users/cwiebe/Development/KrakatoaProject/KrakatoaSR/sharedlib/libKrakatoaSR.dylib (compatibility version 0.0.0, current version 0.0.0)



Right, this has always been kind of an annoying problem when linking our 3rd party dynamic libraries. I’ll do a test here and see if I can come up with a good solution for you.


I reproduced your issue, and found a solution using “install_name_tool”.

Here is a simple setup in OSX to build the most basic Krakatoa program:

Create hello.cpp:

#include <krakatoasr_renderer.hpp>
int main() {
    krakatoasr::krakatoa_renderer r;

Then from the command line, build it like this:

g++ -c -o hello.o hello.cpp -Ipath_to_ksr/include
g++ -o myexecutable hello.o -Lpath_to_ksr/lib-osx-x64 -lKrakatoaSR -ltbb -ltbbmalloc
install_name_tool -change /Users/cwiebe/Development/KrakatoaProject/KrakatoaSR/sharedlib/libKrakatoaSR.dylib ./libKrakatoaSR.dylib myexecutable

After this, make sure that KrakatoaSR.dylib, tbb.dylib and tbbmalloc.dylib are in the same directory as “myexecutable”, and it should link and run. I will also include this repathing in the next release. Thank you for alerting me to the problem. Note: If you want it to work when the dylib files are not in the current directory, you will need to repath libtbb.dylib and libtbbmalloc.dylib also.

Does that get it working for you?


I fixed it by doing the following

install_name_tool -id libKrakatoaSR.dylib

I think the above is the correct way so that specifying DYLD_LIBRARY_PATH will get all 3 shared libraries (including the 2 TBBs)