GFortran compiler error on Mac OS Big Sur I am trying to compile a hello world program in fortran on Mac OS Big Sur. Before updating everything  worked fine.
I compile with this line:
~ % gfortran hw.f90
--&gt; ld: library not found for -lSystem
    collect2: error: ld returned 1 exit status

I have installed gnu gfortran and gcc before updating. Version command output:
~ % gfortran --version
--&gt; GNU Fortran (Homebrew GCC 10.2.0) 10.2.0
    Copyright (C) 2020 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.

~ % gcc --version
--&gt; Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
    Apple clang version 12.0.0 (clang-1200.0.32.28)
    Target: x86_64-apple-darwin20.2.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Output of which command:
~ % which gfortran
--&gt; /usr/local/bin/gfortran

~ % which gcc     
--&gt; /usr/bin/gcc
I have been able to fix the issue with the help of the following two posts:

https://developer.apple.com/forums/thread/666700
https://stackoverflow.com/questions/27314733/make-usr-local-lib-a-default-library-search-path-for-ld-on-mac-os-x

The problem is that after the update the System library is no longer in the search paths of the gcc. I solved this by adding it manually to the zprofile, so that anytime I run the Terminal, variable $LIBRARY_PATH is set.
To fix this issue
Edit file /private/etc/zprofile
Add this to the end of the file:
if [ -z &quot;${LIBRARY_PATH}&quot; ]; then
    export LIBRARY_PATH=&quot;/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib&quot;
else
    export LIBRARY_PATH=&quot;$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib&quot;
fi

Restart Terminal