2017-01-31

dyld: Library not loaded: libboost_system.dylib

Got an error when compile boost library and run a sample program.
$ ./PROGRAM
dyld: Library not loaded: libboost_system.dylib
  Referenced from: /PATH/TO/PROGRAM
  Reason: image not found
Abort trap: 6
Check libraries then tried install_name_tool, but failed.
$ otool -L PROGRAM
PROGRAM:
libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)
libboost_thread.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

$ install_name_tool -change libboost_system.dylib /PATH/TO/libboost_system.dylib PROGRAM
$ install_name_tool -change libboost_thread.dylib /PATH/TO/libboost_thread.dylib PROGRAM
Solution, add the following to .profile or .bash_profile
export DYLD_LIBRARY_PATH=/PATH/TO/BOOST/stage/lib

1 comment:

  1. Use @rpath/libboost_system.dylib instead of just the library name. Then the install_name_tool fix works.

    ReplyDelete