-1

I've barely even started to write the code down that the build started to fail. I can't seem to find a solution anywhere. Here is my code:

#include <iostream>
using namespace std;

struct personne
{
    char nom[30];
    int age;
}
;

All I get is the "Undefined symbol: _main" error and I can't do anything with the code...

Ribal
  • 1
  • 5
    You need a main function. – tkausl May 20 '22 at 23:13
  • 1
    All C++ programs require an entry point. Usually, and in your case from the looks of it, this is `int main() { /*code that does stuff to get your program logic started goes here*/ }` Right now all you need to satisfy the compiler ([the linker, really](https://stackoverflow.com/questions/6264249/how-does-the-compilation-linking-process-work)) is an empty `main` function. – user4581301 May 20 '22 at 23:15
  • 1
    Side note: Good on you for compiling early. Do it and test early and often. But not quite this early as a `main` function is a must. – user4581301 May 20 '22 at 23:19
  • As a side note: What are you trying to do with this. What I mean is: what do you expect this to do if it were to compile, because as it reads it does nothing but define a struct, which would produce no observable effects. If this was a header, then include guards are needed and avoid [`using namespace std;`](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice) even more than usually – Lala5th May 20 '22 at 23:35
  • there are two steps to build an application: compile all the source files into object files, then link the object files and any libraries to create the application. The linker is complaining that there’s no `main`, and it’s right. But the good news is that your source file compiled — no errors. Good start! – Pete Becker May 20 '22 at 23:55
  • Thank you so much!! I had written so many functions and was so sad it was succeeding to build! I indeed needed a main function (even an empty one as one of you said! – Ribal May 21 '22 at 11:26

0 Answers0