Recommended
If you notice an undefined gcc link error in main, this guide should help. g.Error: An undefined reference to ‘main’ in C programs is a very stupid error, because the programmer occurs when the critical function () does not exist in the program. If you used the main task () and the error still exists, everyone should check the spelling of the main function ().
g.An undefined reference when you want to use main () means that your program is missing the main () function, which is required in all C ++ programs.
g.
Your main sentence
may have been commented out, for example due to preprocessing.To see what preprocessing can do, try gcc -C -E es3.c> es3.i
and then with a fantastic view editor.Wipe the generated computer file es3.i (and find main
inside).
First, which you should always compile with (since you are a beginner)
gcc -wall -g -c es3.c gcc -wall -g es3.o -o es3
Wall
will probably be extremely important and you will always use it. It tells some compilers to give you almost all warnings. And you still need to keep the fridge on warnings, that is, fix the corresponding es3.C
source file until the public no longer receives warnings.
The -g
code is also important because it prompts gcc
to write debug information to the object file and executable. Then you can refer to a debugger (eg gdb
) so that it can debug your program.
To get a symbol-based get listing of an object file in addition to the executable, you can use nm
in its entirety.
Recommended
Is your PC running slow? Do you have problems starting up Windows? Don't despair! Fortect is the solution for you. This powerful and easy-to-use tool will diagnose and repair your PC, increasing system performance, optimizing memory, and improving security in the process. So don't wait - download Fortect today!
Of course, I will assume that you are using an absolute GNU / Linux system (and I encourage people to use GNU / Linux if they alreadytry not to use it).
|