OS X 上的 gcc 导致 dyld:未加载库:/opt/local/lib/libffi.6.dylib

gcc on OS X leads to dyld: Library not loaded: /opt/local/lib/libffi.6.dylib

$ gcc t0.c
dyld: Library not loaded: /opt/local/lib/libffi.6.dylib
  Referenced from: /opt/local/libexec/llvm-9.0/lib/libLLVM.dylib
  Reason: image not found
fatal error: /opt/local/bin/as: fatal error in /opt/local/bin/clang-mp-9.0

$ gcc --version
gcc (MacPorts gcc9 9.2.0_1) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

有什么帮助吗?

它是如何修复的:

# update ports tree
$ sudo port selfupdate

# uninstall all ports
# note: in my case uninstalling all ports is much faster than
#       auto-rebuilding ports which have/cause linking issues
$ sudo port -fp uninstall installed

# install needed ports
$ port install xxx yyy zzz

# test
$ gcc t0.c
<no errors as expected>

更多信息:https://guide.macports.org/#using.common-tasks