Click here to Skip to main content
15,749,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I'm trying to run some c++ code on my mac but i'm getting an error: **clang: error: linker command failed with exit code 1**
I'm trying to execute multiple .cpp files from vs code but it keeps showing the error.
I think its something to do with the compiler but i'm not sure how to fix it or run it with the compiler and have just been using the execution code provided by my lecturer which seem to be working before but now its not.

What I have tried:

I have to run the code using compiler code:
g++ -Wall -Werror -std=c++14 -O -o M123 carboard.cpp board.cpp game.cpp player.cpp

The 'M123' is the folder name and the '.cpp' files are all the c++ files that include my code in them
Updated 9-Apr-23 17:39pm

1 solution

You probably have a directory (or folder if you prefer) in your current directory called M123 change the destination name to something else, or rename the directory/folder.
e.g. :
[k5054@localhost]$ ls
[k5054@localhost]$ mkdir hello
[k5054@localhost]$ ls
hello  hello.cpp
[k5054@localhost]$ clang++ hello.cpp -o hello
/usr/bin/ld: cannot open output file hello: Is a directory
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
[k5054@localhost]$ clang++ hello.cpp -o helloworld
[k5054@localhost]$ ./helloworld
Hello World
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900