Clang linking error MacOS Big Sur

Hi All,

I am trying to build my helloworld.cpp, but I am having problem since I updated to Big Sur. Below a verbose screenshot of my build error message. Looks like it cannot link the c++ std library?

I have already tried to remove the command line tool and re install it. No luck.

Code Block
Apple clang version 12.0.0 (clang-1200.0.32.27)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
ignoring nonexistent directory "/usr/include/c/v1"
"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx11.0.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name helloworld.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-strict-return -masm-verbose -munwind-tables -fcompatibility-qualified-id-block-type-checking -target-cpu penryn -dwarf-column-info -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb -target-linker-version 609.6 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0 -stdlib=libc -internal-isystem /Library/Developer/CommandLineTools/usr/bin/../include/c/v1 -internal-isystem /usr/local/include -internal-isystem /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include -internal-externc-isystem /usr/include -internal-externc-isystem /Library/Developer/CommandLineTools/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -std=c17 -fdeprecated-macro -fdebug-compilation-dir /Users/***/Documents/CppProject -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fobjc-runtime=macosx-11.0.0 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/4t/my76lgkd0f7c34tybwg9f6km0000gn/T/helloworld-f9d8e9.o -x c /Users/***/Documents/CppProject/helloworld/helloworld.cpp
clang -cc1 version 12.0.0 (clang-1200.0.32.27) default target x86_64-apple-darwin20.1.0
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 11.0.0 0.0.0 -o /Users/***/Documents/CppProject/helloworld/helloworld /var/folders/4t/my76lgkd0f7c34tybwg9f6km0000gn/T/helloworld-f9d8e9.o -lc -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a
ld: library not found for -lc
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The terminal process "/bin/bash '-c', 'clang -std=c17 -stdlib=libc++ -g -v /Users/***/Documents/CppProject/helloworld/helloworld.cpp -o /Users/***/Documents/CppProject/helloworld/helloworld'" terminated with exit code: 1.


Nearly the same problem. In my case it says that /usr/lib/libstdc is not found, but I suppose it should use libc
Similar problem here: ld: library not found for -lSystem

It seems like there is no GCC support in Big Sur (?)

Post not yet marked as solved Up vote reply of vazz Down vote reply of vazz

Similar problem here: ld: library not found for -lSystem
It seems like there is no GCC support in Big Sur (?)

I get the same message when I try to build with GCC as well.
  • while browsing for my problem on OSX Monterey 12.6 ( fresh update from Big Sur )

    ld: library not found for -lSystem

    I came across this thread.

    I reinstalled brew gcc, no change, when I tried to reinstall it from source and got this message

    brew reinstall gcc@9 -s

    Error: Your Command Line Tools are too outdated.

    sudo rm -rf /Library/Developer/CommandLineTools sudo xcode-select --install

    fixed it

Add a Comment
I have the same Problem with clang. If I specify the library path in the developer tools with:

clang helloworld.cpp -L /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib

it compiles fine.
However I need clang to search this path by itself since it is called from another program.
Adding the path or exporting it as DYLNLIBRARYPATH didn't work.
Does anyone know how to do this?
Hi! Does anyone know how to solve this? Reinstalling command line tools didn't help me.

I get the error when I try to use clang from llvm formula from brew in my CMake project.

Code Block
ld: library not found for -lSystem
clang-11: error: linker command failed with exit code 1

I get the error when I try to use clang from llvm formula from brew in my CMake project.

What do the developers of brew and CMake say about this problem?

I have the same issue. I am not able to compile using g++. Any solutions?
anything new ? :/
I'm using Geany, for me it solved.
Any luck with this problem? I have a similar error.

Code Block
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am using LDLIBRARYPATH as below in my make file configuration.

Code Block
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib

Hi, I had the same issue ld: library not found for -lSystem and now I have ld: library not found for -lpthread. Reinstalled Command Line tools, removed llvm from brew still not working.

Does anyone have any idea how to fix this?

I believe it is this: in Big Sur system dynamic link libraries are not available as separate entities. They're pre-loaded. The -l switch for Apple clang still finds them without a -L switch. Gcc does not. There's no solution for Apple libraries. For C++ standard libraries, you have to install the libraries, they should come with g++ compiler if you're installing using brew.

I guess the reasons: Faster loading, faster access, less VM manager resource use, and last but not least, vastly improved security (it stops hijacking).

As suggested by @NavyOwl in the response, adding the following compilation flag fixes the problem:

Code Block
g++ ... -L /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib

In order to make or cmake compile with this flag, one can define an environment variable (e.g., set in your IDE / bash):

Code Block bash

If you are working from command line:

Code Block bash
export LDFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
make # or cmake .

  • A following up of the ld: library not found for -lSystem problem: I also came across this problem when building fortran90. I solved this problem by installing the CommandLineTool from Xcode. Before solving this problem, I found that there is no CommandLineTools folder in my Library folder so that the suggestion of export LDFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib didn't work for me.

    To install the commandlinetool, one can check this website, It is very simple to install, just type in xcode-select --install in the Terminal and it takes a while to install.

    Hope my solution can solve your problem as well.

Add a Comment
If you’re curious as to the backstory here, see this post.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + ""
  • Thank you.

    The backstory is very interesting and it looks like the setup imposed by Apple is sensible, as long, as you play by their rules (which is not what people may want, but I digress....)

    Now. I can do the following

    $ clang something.o -o somethingexecutable

    and things work as advertised, but if I do

    $ ld -e _main -o basepgm -lSystem basepgm.o ld: library not found for -lSystem

    which is what people are complaining about.

    Note that, AFAIU, I have the proper Command Line tools installed.

    $ xcode-select -v xcode-select version 2395. $ xcode-select -p /Applications/ $ clang --version Apple clang version 13.1.6 (clang-1316.0.21.2) Target: x86_64-apple-darwin21.4.0 Thread model: posix InstalledDir: /Applications/ $ ld -v @(#)PROGRAM:ld  PROJECT:ld64-762 BUILD 06:28:45 Feb 18 2022 configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em LTO support using: LLVM version 13.1.6, (clang-1316.0.21.2) (static support for 28, runtime is 28) TAPI support using: Apple TAPI version 13.1.6 (tapi-1316.0.7.3)

    ... so, how do you call ld from the command line to produce an executable? Any idea about how to fix the thing?

    Either my setup is wrong, or Apple need to ensure that ld did the proper and expected thing out of the box (after all Apple has the money, which we all pay every time we use an Apple device).

    All be best


  • I'm sorry I can't read your post. Please repost it as a reply.

Add a Comment

xcode-select --print-path

You may need to change this to your Xcode installation if you separately installed the command line tools and that is the issue:

xcode-select -switch /Applications/

Try also building with clang++ instead of clang. This was causing a linking issue for me.