记录下使用gcc新学的选项,-c,-Wall,-Werror,-O,-Idir,-llibrary,-pthread。目前,无法理解didier老师的Makefile中的-lpthread,-D_UNIX和-lm选项。主要还是要查阅gcc的官方manual,分为编译选项和link选项等。。。比如4.4.5的使用手册:
http://gcc.gnu.org/onlinedocs/gcc-4.4.5/gcc/index.html#toc_Option-Index
file.cc
file.cp
file.cxx
file.cpp
file.CPP
file.c++
file.C
C++ source code which must be preprocessed. Note that in .cxx, the last two letters must both be literally x. Likewise, .C
refers to a literal capital C.
-c Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the
form of an object file for each source file.
By default, the object file name for a source file is made by replacing the suffix .c, .i, .s, etc., with .o.
Unrecognized input files, not requiring compilation or assembly, are ignored.
-Wall
This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or
modify to prevent the warning), even in conjunction with macros.
-O
-O1 Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function.
With -O, the compiler tries to reduce code size and execution time, without performing any optimizations that take a great
deal of compilation time.
-Idir
Add the directory dir to the head of the list of directories to be searched for header files.
-llibrary
-l library
Search the library named library when linking.
-pthread
Adds support for multithreading with the pthreads library. This option sets flags for both the preprocessor and linker.
-pthread
Add support for multithreading using the POSIX threads library.
-D name
Predefine name as a macro, with definition 1.
-Werror=
Make the specified warning into an error.