g++how to compile a file? say you have test.cc and test.hh now,
to compile and link it: > g++ -c test.cc > g++ -o test
test.othen you can run the exutable "test" you got. GCC docs -
-o output file - -c compile but not link - -L, -I include and
lib paths - -l link a lib - -g insert debugging info in your
exutable - -Wall turn on warnings - -fPIC position independent
code (dosen't work sometimes) - -O optimize Makefilethe easiest
one: # this is a example of Makefile test: test.o g++ -o test
test.o test.o: test.cc test.hh g++ -c test.cc clean: rm test
test.oSomething maybe useful is to tell gcc how to compile all,
say .cc files: %.o:%.cpp g++ -c $< $(INCLUDES)The variable "$<"
refers to dependency. And "$@" is target I stole this longer
example from
http://www.pma.caltech.edu/~physlab/ph21_winter06/make.html, to
show you other than compiling, Makefile can also do automatic
work for you: # Makefile CPP = g++ CPPFLAGS = -g -Wall LDFLAGS =
-lm # If output data is up to date, plot it. plot: output-data
xmgrace outpu