Give libraries @rpath-relative install names #4371
Shared libraries should be optimized for sharing.
I have a common use-case:
The spanner in the works is the install_name upon brew-installed libraries.
A library's install name recommends, "anybody who links to me should look for me at this path".
I link my executable to libvorbis.dylib.
I cannot give that executable to my friend. It's not portable.
Proposal: give every library an @rpath-relative install name. Like
For example: my executable may expand @rpath to
This even works for brew libraries which depend on other brew libraries. libvorbis.dylib could link to libogg.dylib using
A nice aspect of @rpath expansion is that it supports fallbacks. So,
Thus, vorbis could still locate its dependency ogg in the usual absolute manner. Describing the relationship in terms of @rpath does not break that behaviour.
So, we can maintain compatibility yet add flexibility.
Currently on my projects, I have to use post-build scripts like this or this to work around this inflexibility of brew libraries. These scripts are enormous and fragile. They require a lot of manual effort and verification.
I hope I've managed to convey the problem and proposal correctly. Please say so if you'd like any clarification.
The text was updated successfully, but these errors were encountered:
Please always fill out the issue template in future.
We do not build for redistribution; rpath is not the only issue you will find with redistributing Homebrew creating libraries (e.g. cflags). We may accept PRs that make this easier but this isn’t something the maintainers will be working on or we’re soliciting help with.