gcc -g :what will happen

That’s kind of right, but incomplete. -g requests that the compiler and linker generate and retain source-level debugging/symbol information in the executable itself. If… the program happens to later crash and produce a core file (which suggests some problem in the actual code), or a deliberate OS command forced it to core (e.g. kill -SIGQUIT pid), or the program … Read more

Where is the header file on Linux? Why can’t I find ?

conio.h is a C header file used with old MS-DOS compilers to create text user interfaces. Compilers that target other operating systems, such as Linux-based, 32-bit Windows and OS/2, provide equivalent functionality through other header files and libraries. The #include <curses.h> will give you almost all of the functionality provided by conio.h. “ncurses” needs to be installed in the … Read more

GCC -fPIC option

Position Independent Code means that the generated machine code is not dependent on being located at a specific address in order to work. E.g. jumps would be generated as relative rather than absolute. Pseudo-assembly: PIC: This would work whether the code was at address 100 or 1000 Non-PIC: This will only work if the code … Read more

Undefined reference to main – collect2: ld returned 1 exit status

It means that es3.c does not define a main function, and you are attempting to create an executable out of it. An executable needs to have an entry point, thereby the linker complains. To compile only to an object file, use the -c option: The above compiles es3.c to an object file, then compiles a file main.c that would contain the main function, and the linker merges es3.o and main.o into … Read more

What does this GCC error “… relocation truncated to fit…” mean?

You are attempting to link your project in such a way that the target of a relative addressing scheme is further away than can be supported with the 32-bit displacement of the chosen relative addressing mode. This could be because the current project is larger, because it is linking object files in a different order, … Read more