Comp 210 Lab 8: g++ Flags

A quick analysis of the compile command, g++ -Wall -g -o hello hello.c
  • g++
    is the Gnu C++ compiler, though it's smart enough to know how to compile regular plain ol' C files as well. Actually, just g++ hello.c would suffice, but the other flags are recommended.
  • -Wall
    turns all Warnings on.
  • -g
    includes debugging information in the compiled code. Not important if you don't use the debugger.
  • -o hello
    Name the output (executable) file hello. If you don't include this option, g++ will instead put your executable in a file named oh-so-descriptively a.out.
  • hello.c
    The name of the file you're compiling.
  • -lm
    This inludes the math library. Really, this flag is only needed if you want to use functions like sqrt, sin, etc. If used, this flag must be last.

  • Back to Lab 8
    Back to Comp 210 Home