Can't run a program with C. Help!


#1

Hi, I’ve got pretty much 0 experience with programming and I’ve just started to learn C. My problem is that I keep getting the same error over and over again and I do not have enough knowledge to solve this by myself.

I am on Mac, Sierra 10.12.3 and I want to be able to compile and run my program in C (I already have XCode).
I have downloaded this package: gpp-compiler (3.0.7)
Every time I do Compile and Run this is the error I get:

ld: warning: ignoring file /Users/Luca/Desktop/C/Test, file was built for unsupported file format ( 0x23 0x69 0x6E 0x63 0x6C 0x75 0x64 0x65 0x20 0x22 0x73 0x74 0x64 0x69 0x6F 0x2E ) which is not the architecture being linked (x86_64): /Users/Luca/Desktop/C/Test
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I don’t know how to solve this. Can you help me?
The code I used is this:

#include "stdio.h"
int main()
{
printf(“Hello World\n”);
return 0;
}


#2

It looks like you saved the file without a file extension. Try changing the name to Test.c and see what happens.


#3

Thank you!! :slight_smile: