{"action":"created","issue":{"url":"https://api.github.com/repos/conda/conda-build/issues/312","labels_url":"https://api.github.com/repos/conda/conda-build/issues/312/labels{/name}","comments_url":"https://api.github.com/repos/conda/conda-build/issues/312/comments","events_url":"https://api.github.com/repos/conda/conda-build/issues/312/events","html_url":"https://github.com/conda/conda-build/pull/312","id":55678669,"number":312,"title":"Use @rpath in the install name of shared libraries on OS X","user":{"login":"asmeurer","id":71486,"avatar_url":"https://avatars.githubusercontent.com/u/71486?v=3","gravatar_id":"","url":"https://api.github.com/users/asmeurer","html_url":"https://github.com/asmeurer","followers_url":"https://api.github.com/users/asmeurer/followers","following_url":"https://api.github.com/users/asmeurer/following{/other_user}","gists_url":"https://api.github.com/users/asmeurer/gists{/gist_id}","starred_url":"https://api.github.com/users/asmeurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmeurer/subscriptions","organizations_url":"https://api.github.com/users/asmeurer/orgs","repos_url":"https://api.github.com/users/asmeurer/repos","events_url":"https://api.github.com/users/asmeurer/events{/privacy}","received_events_url":"https://api.github.com/users/asmeurer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-27T21:42:49Z","updated_at":"2015-01-27T22:16:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/conda/conda-build/pulls/312","html_url":"https://github.com/conda/conda-build/pull/312","diff_url":"https://github.com/conda/conda-build/pull/312.diff","patch_url":"https://github.com/conda/conda-build/pull/312.patch"},"body":"@rpath will, by convention, point to the lib directory of the environment,\r\nusing @loader_path (a future commit will add this to all shared libraries\r\nautomatically).\r\n\r\nThe install name is copied into depending libraries at link time. This allows\r\nlibraries to refer back to dependent libraries in a relocatable way. As long\r\nas some library that has been loaded has an LC_RPATH pointing to the lib\r\ndirectory, the loader will be able to find the dependencies.\r\n\r\nThe situation works very similarly to the way it does on Linux. The difference\r\nis that in Linux, libraries are loaded by their file name only, whereas on OS\r\nX, they can use arbitrary paths from the install name. This is better, because\r\nit lets us use only a single rpath (the lib directory) to point to\r\neverything.\r\n\r\nThis makes it possible to build packages that link against libraries from a\r\nconda package without conda build, and have them work without calling\r\ninstall_name_tool, using special compiler flags, or setting\r\nDYLD_LIBRARY_PATH.\r\n\r\nThis fixes #279."},"comment":{"url":"https://api.github.com/repos/conda/conda-build/issues/comments/71739676","html_url":"https://github.com/conda/conda-build/pull/312#issuecomment-71739676","issue_url":"https://api.github.com/repos/conda/conda-build/issues/312","id":71739676,"user":{"login":"asmeurer","id":71486,"avatar_url":"https://avatars.githubusercontent.com/u/71486?v=3","gravatar_id":"","url":"https://api.github.com/users/asmeurer","html_url":"https://github.com/asmeurer","followers_url":"https://api.github.com/users/asmeurer/followers","following_url":"https://api.github.com/users/asmeurer/following{/other_user}","gists_url":"https://api.github.com/users/asmeurer/gists{/gist_id}","starred_url":"https://api.github.com/users/asmeurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmeurer/subscriptions","organizations_url":"https://api.github.com/users/asmeurer/orgs","repos_url":"https://api.github.com/users/asmeurer/repos","events_url":"https://api.github.com/users/asmeurer/events{/privacy}","received_events_url":"https://api.github.com/users/asmeurer/received_events","type":"User","site_admin":false},"created_at":"2015-01-27T22:16:16Z","updated_at":"2015-01-27T22:16:16Z","body":"This sets the install name of shared libraries to be `@rpath/relative/path/to/library.dylib`, where `@rpath` should be replaced with `$PREFIX/lib` to give the path to the library.  It also adds the `LC_RPATH` to the libraries like `@loader_path/relative/path/to/lib`. (e.g., for `$PREFIX/lib/R/lib/libR.dylib`, the install name is `@rpath/R/lib/libR.dylib` and the `LC_RPATH` is set to `@loader_path/../../`). \r\n\r\nThe install name ends up getting pulled in at link time, and as long as the loader can find one of the `LC_RPATH`s in the dependency chain, it finds everything.\r\n\r\nI manually applied the changes from the pull request to libpython.dylib, libhdf5.dylib, and libhdf5_hl.dylib, and was able to pip install h5py and run it (without the change, with the current conda python and hdf5 packages, pip install h5py leads to \"Library not loaded: libhdf5.9.dylib\"). I got similar results with R packages\r\n\r\nI believe this change should make developing against conda packages \"just work\", without using install_name_tool, compiler flags, or DYLD_LIBRARY_PATH. In the worst case you may need to add -rpath to your compiler flags if it can't find any of the rpaths at load time.\r\n\r\nThe reason it \"just works\" for Python or R packages is that inside of Python or R, the libpython or libR have already been loaded, and so the `LC_RPATH`s inside of them will be search by the loader, which will point them to the lib directory and the dependent library it is trying to find.\r\n"}}