-
Notifications
You must be signed in to change notification settings - Fork 981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using shared lib Conan packages is broken on OSX #1238
Comments
Thanks very much for your report.
|
I agree with @jondo2010 except a couple of things:
|
@memsharded Yes, the dylibs have been copied to the local bin folder using It's simply that this setup is super less than ideal, to the point of being not useful. I have to With regards to the docs, @lasote, at the bottom of http://docs.conan.io/en/latest/manage_deps/conanfile_txt.html where it talks about rpaths:
I would argue that a more robust approach is as follows:
This would give the consumer much better flexibility in how their binaries link to the shared libraries. For case 1, they would add the absolute path to the folder containing the library to the binaries' RPATH (e.g. The As a further example, let's take a look at how a homebrew-installed lib does it:
|
@jondo2010 thanks for your long explanation. Yes, modify dynamically the rpaths is something we thought about but we didn't get too much feedback about it (so thanks again). I think we should at least:
|
I agree with @jondo2010 as well, I think that the libraries on macOS should have @rpath prepended to them to avoid issues. One of the potential pitfalls of naming the libraries with: Not only that, but conan's convention as mentioned in the documentation, Most libraries that provide precompiled binaries (Qt5 being the biggest example, but also the pre-compiled OSX tbb binaries) do provide them with "@rpath" prepended, and these place nicely in all scenarios. Things like macdeployqt or cmake's own bundle fix up will struggle finding the libraries at the correct locations. |
Hi @lasote, On Mac it's more common to alter the executable itself and set the rpath to something relative to the executable, e.g. @executable_path/../lib (if the "package" is of the bin/lib form), or @executable_path/../../Frameworks if the package is a OSX app bundle. The alternative, if all the imported libraries (through conan) have "naked" install names, would be to actually set the rpath or modify the install names of ALL libraries. I think the "libraries on the same directory" only works for the same working directory. When launching an application from an app bundle, the working directory is the ".app" dir, I think, and the executable is two levels down. I am trying to gather all information on this, as this is all due to different behaviour of the dynamic loader on Linux and macOS. It doesn't help that "@rpath" wasn't a thing prior to 10.5 either. |
It makes sense. Thanks! |
So, the actions to perform in conan could be:
I'm going to add this to the next 0.26 milestone. |
I was trying to come up with a better explanation of how OSX works and turns out Kitware already did it for me some time ago: Also, one of the comments there summarizes the situation quite well. I'm quoting:
Option 1 is really only used by OSX system libraries, where they are guaranteed to be found at a certain location. Options 3 and 4 used to be common place before apple introduced the "@rpath" prefix in 10.5. As for Conan, we have to take into account a few things.
However, some libraries that use CMake already do this a different way (e.g. OpenCV, their install names on mac are |
I'm not sure what version of OSX was in mind when the documentation was written, but on my OSX machine running El Capitan, the Getting Started tutorial does not work at the point of linking to the shared library versions of Poco and OpenSSL.
This is because the shared library install name, and RPATH approach talked about in the documentation will not generally work. The only way the example will work as currently set up, is if you execute it from the bin/ folder. This doesn't work, for example:
Shared libraries on OSX have an "install name" that must match what is referenced in the binary.
Looking at libPocoCrypto:
The install name is "libPocoCrypto.43.dylib" which means that the dynamic linker will ONLY ever be able to find it in the PWD of the parent process, regardless of where the actual binary is located.
The text was updated successfully, but these errors were encountered: