我有一個庫:libfoo.dylib。問題是在命令所示:如何在dylib中指定rpath?
$ install_name_tool -id "@rpath/libfoo.dylib" libfoo.dylib $ install_name_tool -add_rpath "@executable_path/" libfoo.dylib $ gcc -o foo foo.c -lfoo $ ./foo #<==== I want this to work dyld: Library not loaded: @rpath/libfoo.dylib Referenced from: ~/./foo Reason: image not found $ install_name_tool -add_rpath "@executable_path/" foo #<=== I dont want to have to specify here where to look for the library $ ./foo Hello World
如何實現沒有指定在可執行文件編譯圖書館在的目標是什麼?
我*想*您需要編譯並鏈接'libfoo.dylib'和'-headerpad_max_install_names',以確保有足夠的空間存放您嘗試添加的名稱。一旦'libfoo.dylib'具有其安裝名稱,則無論程序的位置如何,'foo'都能夠鏈接到它。 – jww