Reputation: 353
I'm building cyrus sasl2 libraries from source. The libs get installed in /usr/local/lib, and the headers in /usr/local/include/sasl, which is proper.
However, when I run apps that try to use them, I get:
dyld: Library not loaded: /libsasl2.dylib
Referenced from: /usr/sbin/postdrop
Reason: image not found
Trace/BPT trap: 5
Running otool -L on the lib shows a bad relative path:
libsasl2.dylib:
/libsasl2.dylib (compatibility version 3.0.0, current version 3.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
How can I change the way make compiles the library so that the correct rpath is encoded? I read about install_name_tool to change it in the library, but that doesn't seem to work using '-change' since the correct path, '/usr/local/lib/libsasl2.dylib', is longer than the currently encoded one. Shouldn't I be able to set that at the time I build the library somehow?
Thanks.
Upvotes: 3
Views: 367
Reputation: 257
install_name_tool -id "@rpath/libsasl2.dylib" "/usr/local/lib/libsasl2.dylib"
would change LC_ID_DYLIB
of the libsasl2.dylib
. When postdrop links to it, that would be added to LC_LOAD_DYLIB
of postdrop. Then you can add an LC_RPATH
entry of /usr/local/lib
to postdrop and everything would work.
Upvotes: 0