When trying to run an executable I've been sent in Mac OS X, I get the following error
dyld: Library not loaded: libboost_atomic.dylib
Referenced from: /Users/"Directory my executable is in"
Reason: image not found
Trace/BPT trap:5
I have installed the boost libraries and they are located in /opt/local/lib
. I think the problem has something to do with the executable only looking in the directory it is in as when I paste the 'libboost_atomic.dylib' in there, it doesn't mind about it anymore. Unfortunately then it complains it can't find the next boost library.
Is there an easy way to fix this?
I got this error when I tried to install ruby 2.3.1 using rvm. It first told me to run
brew update
, which I did, and then when I tried runningrvm install ruby-2.3.1
, I received the error in this SO question.The fix was to first run
brew upgrade
, apparently according to this superuser.com question you need to do bothbrew update
&&brew upgrade
. Once that was done, I could finally install ruby 2.3.1.You can use
sudo install_name_tool -change
change dylib path Andsudo install_name_tool -id
change dylib nameYou can use the otool command with the -L option for the executable, which will display where the executable is expecting those libraries to be.
If the path to those need changing, use the install_name_tool command, which allows you to set the path to the libraries.
I faced the app crash issue quoting SIGABRT error in thread.Overview of the crash is dyld library not loaded and image not found something like that.
This was seen in xcode 9.3 version.The reason i found out was xcode is not picking up libraries dynamically so i had to do it manually which solved my crash issue.
Follow the below steps: Step 1: Go to Build Phases Step 2: Hit the '+' button at the top and select "New Copy File Phase" Step 3 : Select Destination as Frameworks and Hit the '+' button below to add files. Step 4 : Select Add Other at below, click CMD+SHIFT+G and paste the below path, /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos
Now you will be able to see some swift dylibs, Select all the swift libraries with .dylib extension and click on open.
These will get added to the embedded binaries in the general tab of app.
Create a new group in project folder and add all these libraries.
Now run your app.
Happy Coding
Find all the boost libraries:
and for each
libboost_xxx.dylib
, do:and finally verify using
otool
again:Manpages:
otool
install_name_tool
EDIT While this doesn't necessarily relate to third-party libraries (like boost or Qt), if you are generating the app and
.dylib
from the same Xcode project then you can actually do this without usinginstall_name_tool
by setting the Dynamic Library Install Name within the build settings. Here's an example that allows the app executable to load the.dylib
from../Frameworks/
:For anyone coming to this page because they got this error trying to link a third party framework to their project using Xcode 6.3.1, the problem I ran into was because the library was being created with an older version of the compiler using a different version of swift. The only way to fix this for me was to re-build the framework.
Another reason you might get this is stated in an Apple technical doc..
set the Embedded Content Contains Swift Code (EMBEDDED_CONTENT_CONTAINS_SWIFT) build setting to YES in your app
Here is the link to the full Apple doc that explains it here