dyld: Library not loaded: libWorld.dylib
Referenced from: /Users/pdl/Development/HelloWorld/Hello/Debug/Hello
Reason: image not found
This means that your program is using a dynamic library called libWorld.dylib, although you linked your dynamic library to your program during compiling. But you have to tell your program where is the dylib in run-time.
There are two solutions:
Solution 1: set up dynamic library environment variables for your project in Eclipse
:
1.Right click your project name
, select Run As->Run Configuration
2.Under Environment
tab click New
3.Put DYLD_LIBRARY_PATH
or DYLD_FALLBACK_LIBRARY_PATH
in Name
box
4.Put the path where your libWorld.dylib
file is in Value
box
For example:
if libWorld.dylib
file is in /opt/local/lib/my_dylib
folder, than put the path in the Name
box
Solution 2: set DYLD_LIBRARY_PATH
in your bash configuration file
1.Normally in Mac OS, configuration file is .profile
under ~/
folder, if you don't have this file than create a new file with the same name
2.Edit that file:
Add this line in your .profile
file:
export DYLD_LIBRARY_PATH=PATH_TO_YOUR_DYLIB:$DYLD_LIBRARY_PATH
in my example the PATH_TO_YOUR_DYLIB is opt/local/lib/my_dylib
, so you just add:
export DYLD_LIBRARY_PATH=/opt/local/lib/my_dylib:$DYLD_LIBRARY_PATH
in .profile file
3.Problem solved, in this solution, you don't have to set up dylib path for all eclipse project
PS. DYLD_LIBRARY_PATH is an environment variable to specify the path of your dynamic library
Difference between DYLD_LIBRARY_PATH
and DYLD_FALLBACK_LIBRARY_PATH
please refer to this post
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…