Problem with programming "C" on MacBook Air (Intel Prozessor) "Undefined Symbols for architecture x86_64:
Hello, I've got problems with programming "C" on my MacBook Air (Intel Prozessor).
When I write following code:
#include <stdio.h>
struct Haustier{
char tier [50];
char name [20];
int alter;
float groesse;
};
void printHaustier (struct Haustier h){
printf ("Das Haustier heißt %s, ist %i; Jahre alt und %.2f cm gross.", h.name, h.alter, h.groesse);
}
int main(){
struct Haustier h;
h.name[0]= 'f';
h.name[1]= 'l';
h.name[2]= 'o';
h.alter=55;
h.groesse= 6.22;
printfHaustier(h);
return 0;
}
It prints out following problems:
Undefined symbols for architecture x86_64:
"_main", referenced from:
<initial-undefines>
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
As far as I've researched about problem, it seems to be the wrong installation path for my operating system. Something about the mixing of two different toolchains: C compiler and linker and runtime...? (actually I don't know anything about that, I am a bloody beginner).
The interesting thing is that I actually was careful about the operating system (Intel vs M1/M2 Chips) and installed as far as I know VisualStudioCode for architecture x86_64. And then adding the Install-packs: "Code runner" and "C/C++".
When I try another basic code like:
#include <stdio.h>
int main() {
printf("Hello World!");
return 0;
}
It actually prints out the "Hello World".
I don't know what I did wrong and how I could save that problem. Any Help? Thank you!
MacBook Air (2018 – 2020)