GCC Compling

Okay, so I've successfully installed GCC on Mac 10.6.8 Snow Leopard. But once it's installed and stuff, how do you use it to compile a program? I have the program I want to run in a nice .cpp file in my main directory. Please help, I know I sound like a dork, but I can't find out how to compile a .cpp file.
Command line!

Basic format:
g++ <input_files>

A few handy flags (add these before your input files):

To choose an output file:
-o <output_file_name_and_path>

To follow the standard strictly:

To give more warnings as to what you might be doing wrong:

To suppress warnings:

To add debug information that GDB might be interested in:

To link with a library (standard library is linked with by default):

To add a directory to search for libraries:

To add a directory to search for headers:

To compile a file without linking it against anything:

To enable optimization (do not use unless you're sure the program works):
-O<0, 1, 2>


Is it a Terminal command?
closed account (Dy7SLyTq)
not all of them. the first is and then everything after is the flags
Esample (see Albatross answer for more detailed infos):

step1: compile only (create an object file)
g++ -c -o obj_file.o source_file.cpp

step2: linking (produces the final "binfile")
g++ -o binfile main.o obj_file.o objfile2.o ...
Topic archived. No new replies allowed.