0

Just posted a simple c code and gotten this error message. can anyone explain where the problem could be?

ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) mac@MACs-MacBook-Pro-2 C % cd "/Users/mac/C/" && g++ tes.c++ -o tes && "/Users/mac/C/"tes Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable 
5
  • you have to compile with gcc and not g++ Commented Mar 4, 2021 at 23:47
  • Please show your code. Commented Mar 4, 2021 at 23:48
  • "Undefined symbol main" usually means you're missing the critical main() function. Commented Mar 4, 2021 at 23:49
  • Thank you all for the answers. I'm actually new in programming.. here is the code, it just a basic 'hello world' algorithm #include <stdio.h> int main() { printf("Hello, World!"); return 0; } Commented Mar 6, 2021 at 0:29
  • @kaylum please take a look Commented Mar 6, 2021 at 0:30

1 Answer 1

2

you have to compile with gcc and not g++, g++ is to compile .cpp or .cc files

gcc tes.c++ -o tes 
Sign up to request clarification or add additional context in comments.

3 Comments

Last login: Fri Mar 5 02:23:16 on ttys002 mac@MACs-MacBook-Pro-2 ~ % gcc clang: error: no input files mac@MACs-MacBook-Pro-2 ~ % ... Here is the message from my terminal, I thought gcc compiler was installed successfully too. I initially installed g++ and I did the same for gcc , I don't know where the problem is , please help
cd Users/mac/C/ && gcc tes.c -o tes && ./Users/mac/C/tes
or, if your file is a c++ file: cd Users/mac/C/ && g++ tes.cpp -o tes && ./Users/mac/C/tes NB: c++ files have .cpp extension file name and not .c++

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.