0
$ 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.

Any help?

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
pmor
  • 5,392
  • 4
  • 17
  • 36
  • Are you on an apple silicon Mac? – Daniel A. White Jan 27 '22 at 22:20
  • Yes.___________ – pmor Jan 27 '22 at 22:30
  • That’s likely the problem. Ensure you flip your shell/env to the correct architecture for what you are building and linking against – Daniel A. White Jan 27 '22 at 23:20
  • I don't understand. I am on OS X, compiling a simple C program for OS X from the terminal. – pmor Jan 27 '22 at 23:30
  • right. it looks like your version of gcc is compiled for intel processors, not for arm/apple silicon. you'll have to load an intel environment and shell to get the right dynamic libraries pointed at it. – Daniel A. White Jan 28 '22 at 02:56
  • Then, I misunderstood your "apple silicon Mac". The OS X I use is running on Intel CPU. Previously I could compile `t0.c` just fine, but now there is a `Library not loaded`. – pmor Jan 28 '22 at 14:50

1 Answers1

0

How it was fixed:

# 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>

More info: https://guide.macports.org/#using.common-tasks.

pmor
  • 5,392
  • 4
  • 17
  • 36