Home > database >  (Clang Error) compilation error: ld: library not found for -lcrt0.o. Any ideas?
(Clang Error) compilation error: ld: library not found for -lcrt0.o. Any ideas?

Time:11-11

The full terminal output is as follows:

>g   -std=c  98 -static mainP1.o  -o mainP1
>
>ld: library not found for -lcrt0.o
>
>clang: error: linker command failed with exit code 1 (use -v to see invocation)
>
>make: *** [mainP1] Error 1

I'm on a 2020 MacBook Pro with an intel CPU using Visual Studio Code. When I write basic OOP programs in C it compiles fine without any clang errors. However, when working with big OOP programs with multiple classes inheriting from a base class I would get this error.

I tried searching online for solutions, but no solution or explanation was found. I double-checked my makefile to ensure I was not linking classes incorrectly. I thought maybe I should just dual-boot with UBUNTU Linux to avoid this weird XCODE issue I was encountering with clang, but that was also a fruitless endeavor.

CodePudding user response:

The problem was my compiler path in Visual Studio Code. I changed it to clang , and now all my code compiles and executes without any problems.

How I changed it:

  1. CMD SHIFT P
  2. Typed in: C/C : Edit Configurations (UI)
  3. Made sure that "Mac" was selected under configuration name.
  4. Changed Compiler Path to: /usr/bin/clang
  • Related