在使用CodeLite编译动态库的时候,可以通过在Linker > Linker Options中添加:
-install_name @executable_path/libXXX.so
的方式更改动态库的Install Name。
在控制台中输入man ld之后, 会显示ld的帮助信息。其中包含-install_name参数的详细描述:
-install_name name
Sets an internal "install path" (LC_ID_DYLIB) in a dynamic library. Any clients linked against the library will
record that path as the way dyld should locate this library. If this option is not specified, then the -o path
will be used. This option is also called -dylib_install_name for compatibility.
在类Unix系统下,动态库的名字应该以“lib”开头。在应用程序链接阶段,如果想链接一个动态库,需以去掉“lib”和扩展名后的库名来进行链接。比如,如果要链接一个名为libXXX.so的动态库,需要通过设置-lXXX来进行链接。
参考
https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html
http://www.eyrie.org/~eagle/notes/rpath.html
http://thecourtsofchaos.com/2013/09/16/how-to-copy-and-relink-binaries-on-osx/
http://osiris.laya.com/coding/dylib_linking.html
https://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-names.html