I am trying to link the library libssh2.1.dylib to my iPhone Xcode project but I get this error when I try to link it. If I don't add this as a framework I get Symbols not found error. Now /Users/Matt/Documents/Development/iPhoneApps/Portscanner/lib/libssh2.1.dylib is not the correct pathway to that file. I downloaded the library off the internet and its the pathway of the Author's computer. I have the file located in a totally different place. How do I change the pathway reference? Heres the error I get:
dyld: Library not loaded: /Users/Matt/Documents/Development/iPhoneApps/PortScanner/lib/libssh2.1.dylib
Referenced from: /var/mobile/Applications/5353E047-05FE-42E4-8F32-617E8D02A11D/Port Scanner.app/Port Scanner
Reason: image not found
You can use the install_name_tool to change the installed path name on a .dylib file:
Example of changing an install name:
install_name_tool -id <yourpath>/libssh2.1.dylib /Users/Matt/Documents/Development/iPhoneApps/Portscanner/lib/libssh2.1.dylib
- first parameter is the path that you want
- second parameter is the real path to the file so drag the file in from the Finder
Also you may need to change dependency names too, and you can use the same tool to do that:
install_name_tool -change <old path> <new path> <library name>
You can check what the current names are using the otool. So you can verify the change with the otool like this:
otool -D libssh2.1.dylib
and dependencies with otool -L libssh2.1.dylib
Or you can get the source code and rebuild it yourself with the current path in it.
If you need a relative path you should look into changing your install name to @rpath/libssh2.1.dylib and add the path to your project settings.
来源:https://stackoverflow.com/questions/3794737/dyld-library-not-loaded