-1

I was looking at a makefile and I get what -o,-c do but what does -g do and mean.

kron maz
  • 131
  • 1
  • 6

3 Answers3

1

This isn't related to make. You should be looking at the documentation for your compiler. For example, GCC's options are summarized here. If you search there you'll find that -g is a debug option described here.

If you use a different compiler you should check the documentation for that compiler (however, the vast majority of C compilers use the same basic options so it's probably the same for yours).

MadScientist
  • 92,819
  • 9
  • 109
  • 136
0

Generally -g option in C compilers adds debugging information to the executable file, so you can debug your executable using

gdb

.See How to debug a C program for more details about debugging C programs.

gile
  • 5,580
  • 1
  • 25
  • 31
-1

-g forces gcc to add debugging information to the compiled code which allows you to more easily debug it with gdb.

Unless you or someone else working with your code is going to be using gdb, there's no reason to include that flag.

From the gcc man pages:

On most systems that use stabs format, -g enables use of extra debugging information that only GDB can use; this extra information makes debugging work better in GDB but will probably make other debuggers crash or refuse to read the program.

https://linux.die.net/man/1/gcc

Jason Warta
  • 430
  • 5
  • 8