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:
- CMD SHIFT P
- Typed in: C/C : Edit Configurations (UI)
- Made sure that "Mac" was selected under configuration name.
- Changed Compiler Path to: /usr/bin/clang