dyld: Library not loaded ... Reason: Image not found
Solution 1
Find all the boost libraries (where exefile
is the name of your executable):
$ otool -L exefile
exefile:
@executable_path/libboost_something.dylib (compatibility version 0.7.0, current version 0.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
and for each libboost_xxx.dylib
, do:
$ install_name_tool -change @executable_path/libboost_something.dylib /opt/local/lib/libboost_something.dylib exefile
and finally verify using otool
again:
$ otool -L exefile
exefile:
/opt/local/lib/libboost_something.dylib (compatibility version 0.7.0, current version 0.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
Manpages: otool
install_name_tool
EDIT A while back I wrote a python script (copy_dylibs.py
) to work out all this stuff automatically when building an app. It will package up all libraries from /usr/local
or /opt/local
into the app bundle and fix references to those libraries to use @rpath
. This means you can easily install third-party library using Homebrew and package them just as easily.
I have now made this script public on github.
Solution 2
This worked for me:
brew upgrade node
Solution 3
In the target's General
tab, there is a section called Frameworks, Libraries, and Embedded Content
Click on the +
sign, add required framework
and the crash is resolved.
Solution 4
After upgrade Mac OS to Mojave. I tried to install npm modules via yarn
command I got error:
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.60.dylib
Referenced from: /usr/local/bin/node
Reason: image not found
Abort trap: 6
Was fixed with:
brew update
brew upgrade
Solution 5
For some, this could be as easy as setting the system path for dynamic libraries. On OS X, this is as simple as setting the DYLD_LIBRARY_PATH
environment variable. See:
rwolst
Updated on November 04, 2021Comments
-
rwolst over 2 years
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?
-
VenushkaT over 9 years@trojanfoe can you please explain here what is the exefile is it be a tool exec file path ? isnt it ?
-
Leo about 7 yearsIt may seem stupid, but I wonder what value should I set
DYLD_LIBRARY_PATH
to? -
markshiz about 7 years@Caesar Set it to the directory of wherever the dylibs you're trying to link are located.
-
tglas over 6 yearsAfter recompiling the executable I have to repeat this process - quite annoying during development.
-
frankliuao almost 6 yearsActually the better way is to use
DYLD_LIBRARY_PATH
to modify the search path. The other answer has got this. -
ScottyBlades almost 6 years'exefile': No such file or directory
-
brunouno over 5 years@ScottyBlades
exefile
stands for the executable file you're trying to run. In my case,otool -L /usr/local/bin/php
did the trick. -
Joe Sleiman over 5 yearswhat should i add ? there's a lot of files
-
trojanfoe over 5 yearsYou cannot expect your users to change
DYLD_LIBRARY_PATH
. The correct solution is to include non-standard libraries with the.app
and the user won't have to do anything. The developer, however, may still have to hack the loader path as per my answer. -
cn00 about 5 yearsI create a cocoa framework dynamic library project, it works, and compared with my bad cmake generated project find this different, and fixed it, it works on iOS.
-
diegoaguilar almost 5 yearsWhat is this doing, though?
-
Hugo Nogueira over 4 years@diegoaguilar this is reinstalling
node
using homebrew. Probably another installation broke node path. Also worked for me. -
Ishan over 4 yearsMy intelliJ started throwing this error when I recently updated xcode. I was trying to run a node.js server through intellij. I wasn't sure what went wrong. Running
node --version
on my system resulted in the same error. Running the above two commands solved my problem. -
Matt Kneiser over 4 yearsThanks! Worked for me when Homebrew messed up bash. In my case I needed to run
install_name_tool
as root to get over the issue. This one-liner inspects all the dylibs for a binary:otool -L /usr/local/bin/bash | awk -F' ' '{print $1}' | tail -n +2 | xargs -I{} ls {}
-
Michael Behrens over 4 yearsIn my case, I also ran the
brew cleanup
command, which is good to do at times if you want to get rid of old versions. -
JBarros35 about 4 yearsthis is not IOS issue.
-
Mo Farhand about 4 years@Himanshu I have libcppreset for my project! it has a lot of dependency from boost and ... I run a bash script to change them with install_name_tool but for the
LC_ID_DYLIB
I can't so need to make a symlink in usr/loca/opt ! is there any way to figure out ? :| It's painfull :( -
Jivan about 4 yearsPeople need to stop recommending doing
brew upgrade
just like that. This can be a massive disruptor for one's entire system. Instead, isolate what needs to be upgraded and upgrade that only. -
Buraco about 4 yearsRegarding to @MichaelBehrens's comment, I run
brew cleanup
then it fixed. -
Onema almost 4 yearsUsing this worked for me, unfortunately, I still don't know what cause of the issue to begin with or why updating, upgrading and cleaning up solve the issue
-
Pianistprogrammer almost 4 yearsthis worked totally for me, however, while trying to do the cleanup, i ran into some permission issue, if you also have this trouble, try running sudo chown -R $(whoami) /usr/local/lib then try running the brew cleanup again
-
Harry Moreno almost 4 yearsI still get
ImportError: cannot import name 'ssl' from 'urllib3.util.ssl_' (/Users/foo/.local/share/virtualenvs/TMIWqqTS/lib/python3.7/site-packages/urllib3/util/ssl_.py)
after running this -
Harry Moreno almost 4 yearsI fixed my follow up error by reinstalling python. I use asdf to manage my language versions so I did
asdf uninstall python 3.7.3
(I was using 3.7.3, specify here the version you have) and then ranasdf install python 3.7.3
. -
Cadu De Castro Alves almost 4 yearsIt worked for me after updating macOS Catalina. Thanks!
-
Ejaz Karim over 3 yearsany explanations on this would be helpful.
-
YuAn Shaolin Maculelê Lai over 3 yearsHere's the other way. Please take a look. github.com/eXolnet/homebrew-deprecated/issues/27
-
trojanfoe over 3 years@YuAnShaolinMaculelêLai Sorry I don't understand what you mean.
-
trojanfoe over 3 yearsLooks to me like the executable shouldn't even be linking against
libssl.1.0.0.dylib
, but ratherlibssl.1.dylib
, which will be symlinked to the exact version on the system while maintaining API compatibility. See this. -
inaki about 3 yearsSame here, I fixed it with
brew upgrade node
(OSX Catalina) -
shorol about 3 yearsif till not work : brew services start php
-
desu sai venkat over 2 yearsAdd the framework and set the framework to
Embed & Sign
-
Jeremy Moritz over 2 yearsThis should be the accepted answer. Save most people a lot of hassle.
-
trojanfoe over 2 years@JeremyMoritz Except that the question doesn't even mention
node
and is not tagged withnode
. It's an answer to a different question. -
Joana Carvalho about 2 yearsI had a similar problem dyld: Library not loaded:/usr/local/opt/fftw/lib/libfftw3f.3.dylib. After checking many possible solutions I just did brew install fftw and it worked for me. Thanks @brunouno
-
Sam Ginrich about 2 years@trojanfoe .app? Have a test executable, trying to link some .dylib . Linux is same with LD_LIBRARY_PATH
-
Sam Ginrich about 2 yearsSo easy. Thank you! Wonder, what other answers are about, and how brew would do a similair thing ...