Compiled Libmt.dylib, and test program calls, are normal. The problem occurs when the call is normal in Xcode and the implicit call is present.
Tips
Dyld:library not loaded.
Even the presence of/usr/lib/limt.dylib also reported errors. Suspect that the app is not searching for this dylib when it runs.
In the Mac platform environment, the dynamic Library (dylib) has an "install name", which is a path that exists in the dynamic library, indicating where the runtime is going to find the library. When the dynamic library is connected, the path is stored in a binary file, so the program can follow this path to find the dynamic library, otherwise it cannot load the dynamic library.
Normal can invoke the dynamic library, through the Otool tool to view the install name.
Mac-mini:bin root# Otool-L libmt.dylib libmt.dylib:/usr/lib/libmt.dylib (Compatibility version0.0.0, current version0.0.0) /usr/lib/libsystem.b.dylib (Compatibility version1.0.0, current version1214.5.1) /usr/lib/libz.1. Dylib (Compatibility version1.0.0, current version1.2.5) /USR/LIB/LIBXML2.2. Dylib (Compatibility version10.0.0, current version10.9.0)
This means that the dynamic library can be found either by setting the environment variable Dyld_library_path or by placing the dynamic library in the specified location, that is, install name.
The install name can be set through the Install_name_tool tool, and the @rpath keyword can be used to specify a relative path to the installation directory by@executable_path,@loader_path关键字指定路径到运行目录。
Otool Setting the Install name
" /usr/lib/libmt.dylib " libmt.dylib
or relative path
"@rpath /lib/libmt.dylib " libmt.dylib
Reference
Http://www.chilkatforum.com/questions/4235/how-to-distribute-a-dylib-with-a-mac-os-x-application
Http://stackoverflow.com/questions/4876740/xcode-keeps-searching-dylib-at-wrong-path
Build dynamic libraries for IOS and load them at runtime