Source: osx snow leopard – Where do I set DYLD_LIBRARY_PATH on Mac OS X, and is it a good idea? – Super User
It’s an environment variable and as such is usually set in Terminal by
export DYLD_LIBRARY_PATH=someValue
One should never set export DYLD_LIBRARY_PATH
on your system.
Shared library paths can be fixed using otool -L
and install_name_tool
.
For instance, if you compile Perl DBD-MySQL you won’t be able to use it as the linker doesn’t know where you’ve installed MySQL.
># make
....
># otool -L blib/arch/auto/DBD/mysql/mysql.bundle
blib/arch/auto/DBD/mysql/mysql.bundle:
libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
#> install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib blib/arch/auto/DBD/mysql/mysql.bundle
># otool -L blib/arch/auto/DBD/mysql/mysql.bundle
blib/arch/auto/DBD/mysql/mysql.bundle:
/usr/local/mysql/lib/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
#> make test
...
Result: PASS
#> make install
This is as simple as that.
—————————————————————————————-
In Xcode 4 you can add it to the project Scheme to avoid errors like this one:
dyld: Library not loaded: @loader_path/libLeap.dylib
Referenced from: /Users/paulsolt/Library/Developer/Xcode/DerivedData/LeapTest-eqcxmzewheyjusgrcszyvlcxlgna/Build/Products/Debug/LeapTest
Reason: image not found
-
In the Menu click on “Product” -> “Edit Scheme” -> “Arguments” tab -> Add “Environment Variables” -> Key: DYLD_LIBRARY_PATH Value: /Users/MyUserAccount/path/to/lib
-
Change the path to your user account and the full path to the library folder.
-
You should be able to build and run.