欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

gcc

系統(tǒng) 1774 0

gcc使用的方法 -- 作者: www.linuxfans.org mozilla
1。gcc包含的c/c++編譯器
gcc,cc,c++,g++,gcc和cc是一樣的,c++和g++是一樣的,一般c程序就用gcc編譯,c++程序就用g++編譯

2。gcc的基本用法
gcc test.c這樣將編譯出一個名為a.out的程序
gcc test.c -o test這樣將編譯出一個名為test的程序,-o參數(shù)用來指定生成程序的名字

3。為什么會出現(xiàn)undefined reference to 'xxxxx'錯誤?
首先這是鏈接錯誤,不是編譯錯誤,也就是說如果只有這個錯誤,說明你的程序源碼本身沒有問題,是你用編譯器編譯時參數(shù)用得不對,你沒有指定鏈接程序要用到得庫,比如你的程序里用到了一些數(shù)學(xué)函數(shù),那么你就要在編譯參數(shù)里指定程序要鏈接數(shù)學(xué)庫,方法是在編譯命令行里加入-lm。

4。-l參數(shù)和-L參數(shù)
-l參數(shù)就是用來指定程序要鏈接的庫,-l參數(shù)緊接著就是庫名,那么庫名跟真正的庫文件名有什么關(guān)系呢?
就拿數(shù)學(xué)庫來說,他的庫名是m,他的庫文件名是libm.so,很容易看出,把庫文件名的頭lib和尾.so去掉就是庫名了。

好了現(xiàn)在我們知道怎么得到庫名了,比如我們自已要用到一個第三方提供的庫名字叫l(wèi)ibtest.so,那么我們只要把libtest.so拷貝到/usr/lib里,編譯時加上-ltest參數(shù),我們就能用上libtest.so庫了(當(dāng)然要用libtest.so庫里的函數(shù),我們還需要與libtest.so配套的頭文件)。

放在/lib和/usr/lib和/usr/local/lib里的庫直接用-l參數(shù)就能鏈接了,但如果庫文件沒放在這三個目錄里,而是放在其他目錄里,這時我們只用-l參數(shù)的話,鏈接還是會出錯,出錯信息大概是:"/usr/bin/ld: cannot find -lxxx",也就是鏈接程序ld在那3個目錄里找不到libxxx.so,這時另外一個參數(shù)-L就派上用場了,比如常用的X11的庫,它放在/usr/X11R6/lib目錄下,我們編譯時就要用-L/usr/X11R6/lib -lX11參數(shù),-L參數(shù)跟著的是庫文件所在的目錄名。再比如我們把libtest.so放在/aaa/bbb/ccc目錄下,那鏈接參數(shù)就是-L/aaa/bbb/ccc -ltest

另外,大部分libxxxx.so只是一個鏈接,以RH9為例,比如libm.so它鏈接到/lib/libm.so.x,/lib/libm.so.6又鏈接到/lib/libm-2.3.2.so,如果沒有這樣的鏈接,還是會出錯,因為ld只會找libxxxx.so,所以如果你要用到xxxx庫,而只有l(wèi)ibxxxx.so.x或者libxxxx-x.x.x.so,做一個鏈接就可以了ln -s libxxxx-x.x.x.so libxxxx.so

手工來寫鏈接參數(shù)總是很麻煩的,還好很多庫開發(fā)包提供了生成鏈接參數(shù)的程序,名字一般叫xxxx-config,一般放在/usr/bin目錄下,比如gtk1.2的鏈接參數(shù)生成程序是gtk-config,執(zhí)行g(shù)tk-config --libs就能得到以下輸出"-L/usr/lib -L/usr/X11R6/lib -lgtk -lgdk -rdynamic -lgmodule -lglib -ldl -lXi -lXext -lX11 -lm",這就是編譯一個gtk1.2程序所需的gtk鏈接參數(shù),xxx-config除了--libs參數(shù)外還有一個參數(shù)是--cflags用來生成頭文
件包含目錄的,也就是-I參數(shù),在下面我們將會講到。你可以試試執(zhí)行g(shù)tk-config --libs --cflags,看看輸出結(jié)果。
現(xiàn)在的問題就是怎樣用這些輸出結(jié)果了,最苯的方法就是復(fù)制粘貼或者照抄,聰明的辦法是在編譯命令行里加入這個`xxxx-config --libs --cflags`,比如編譯一個gtk程序:gcc gtktest.c `gtk-config --libs --cflags`這樣就差
不多了。注意`不是單引號,而是1鍵左邊那個鍵。

除了xxx-config以外,現(xiàn)在新的開發(fā)包一般都用pkg-config來生成鏈接參數(shù),使用方法跟xxx-config類似,但xxx-config是針對特定的開發(fā)包,但pkg-config包含很多開發(fā)包的鏈接參數(shù)的生成,用pkg-config --list-all命令可以列出所支持的所有開發(fā)包,pkg-config的用法就是pkg-config pagName --libs --cflags,其中pagName是包名,是pkg-config--list-all里列出名單中的一個,比如gtk1.2的名字就是gtk+,pkg-config gtk+ --libs --cflags的作用跟gtk-config --libs --cflags是一樣的。比如:gcc gtktest.c `pkg-config gtk+ --libs --cflags`。

5。-include和-I參數(shù)
-include用來包含頭文件,但一般情況下包含頭文件都在源碼里用#include xxxxxx實現(xiàn),-include參數(shù)很少用。-I參數(shù)是用來指定頭文件目錄,/usr/include目錄一般是不用指定的,gcc知道去那里找,但是如果頭文件不在/usr/include里我們就要用-I參數(shù)指定了,比如頭文件放在/myinclude目錄里,那編譯命令行就要加上-I/myinclude參數(shù)了,如果不加你會得到一個"xxxx.h: No such file or directory"的錯誤。-I參數(shù)可以用相對路徑,比如頭文件在當(dāng)前目錄,可以用-I.來指定。上面我們提到的--cflags參數(shù)就是用來生成-I參數(shù)的。

6。-O參數(shù)
這是一個程序優(yōu)化參數(shù),一般用-O2就是,用來優(yōu)化程序用的,比如gcc test.c -O2,優(yōu)化得到的程序比沒優(yōu)化的要小,執(zhí)行速度可能也有所提高(我沒有測試過)。

7。-shared參數(shù)
編譯動態(tài)庫時要用到,比如gcc -shared test.c -o libtest.so

8。幾個相關(guān)的環(huán)境變量
PKG_CONFIG_PATH:用來指定pkg-config用到的pc文件的路徑,默認(rèn)是/usr/lib/pkgconfig,pc文件是文本文件,擴展名是.pc,里面定義開發(fā)包的安裝路徑,Libs參數(shù)和Cflags參數(shù)等等。
CC:用來指定c編譯器。
CXX:用來指定cxx編譯器。
LIBS:跟上面的--libs作用差不多。
CFLAGS:跟上面的--cflags作用差不多。
CC,CXX,LIBS,CFLAGS手動編譯時一般用不上,在做configure時有時用到,一般情況下不用管。
環(huán)境變量設(shè)定方法:export ENV_NAME=xxxxxxxxxxxxxxxxx

9。關(guān)于交叉編譯
交叉編譯通俗地講就是在一種平臺上編譯出能運行在體系結(jié)構(gòu)不同的另一種平臺上,比如在我們地PC平臺(X86 CPU)上編譯出能運行在sparc CPU平臺上的程序,編譯得到的程序在X86 CPU平臺上是不能運行的,必須放到sparc CPU平臺上才能運行。
當(dāng)然兩個平臺用的都是linux。

這種方法在異平臺移植和嵌入式開發(fā)時用得非常普遍。

相對與交叉編譯,我們平常做的編譯就叫本地編譯,也就是在當(dāng)前平臺編譯,編譯得到的程序也是在本地執(zhí)行。

用來編譯這種程序的編譯器就叫交叉編譯器,相對來說,用來做本地編譯的就叫本地編譯器,一般用的都是gcc,但這種gcc跟本地的gcc編譯器是不一樣的,需要在編譯gcc時用特定的configure參數(shù)才能得到支持交叉編譯的gcc。

為了不跟本地編譯器混淆,交叉編譯器的名字一般都有前綴,比如sparc-xxxx-linux-gnu-gcc,sparc-xxxx-linux-gnu-g++ 等等

10。交叉編譯器的使用方法
使用方法跟本地的gcc差不多,但有一點特殊的是:必須用-L和-I參數(shù)指定編譯器用sparc系統(tǒng)的庫和頭文件,不能用本地(X86)
的庫(頭文件有時可以用本地的)。
例子:
sparc-xxxx-linux-gnu-gcc test.c -L/path/to/sparcLib -I/path/to/sparcInclude

- 作者: michaelbob 2005年03月20日, 星期日 14:08  回復(fù)(0) |  引用(0) 加入博采

[轉(zhuǎn)貼] GCC 使用指南
:[轉(zhuǎn)貼] GCC 使用指南
使用語法:


option | filename ]...

其中 option 為 gcc 使用時的選項(后面會再詳述),
   而 filename 為欲以 gcc 處理的文件

說明:
這 C 與 C++ 的 compiler 已將產(chǎn)生新程序的相關(guān)程序整合起來。產(chǎn) 生一個新的程序需要經(jīng)過四個階段:預(yù)處理、編譯、匯編、連結(jié),而這兩 個編譯器都能將輸入的文件做不同階段的處理。雖然原始程序的擴展名可 用來分辨編寫原始程序碼所用的語言,但不同的compiler,其預(yù)設(shè)的處理 程序卻各不相同:

gcc  預(yù)設(shè)經(jīng)由預(yù)處理過(擴展名為.i)的文件為 C 語言,并於程式
      連結(jié)階段以 C 的連結(jié)方式處理。

g++  預(yù)設(shè)經(jīng)由預(yù)處理過(擴展名為.i)的文件為 C++ 語言,并於程序連結(jié)階段以 C++ 的連結(jié)方式處理。

原始程序碼的擴展名指出所用編寫程序所用的語言,以及相對應(yīng)的處理方法:

   .c  C 原始程序         ; 預(yù)處理、編譯、匯編
   .C  C++ 原始程序        ; 預(yù)處理、編譯、匯編
   .cc C++ 原始程序        ; 預(yù)處理、編譯、匯編
   .cxx C++ 原始程序        ; 預(yù)處理、編譯、匯編
   .m  Objective-C 原始程序    ; 預(yù)處理、編譯、匯編
   .i  已經(jīng)過預(yù)處理之 C 原始程序  ; 編譯、匯編
   .ii 已經(jīng)過預(yù)處理之 C++ 原始程序 ; 編譯、匯編
   .s  組合語言原始程序      ; 匯編
   .S  組合語言原始程序      ; 預(yù)處理、匯編
   .h  預(yù)處理文件(標(biāo)頭文件)    ; (不常出現(xiàn)在指令行)

其他擴展名的文件是由連結(jié)程序來處理,通常有:
   .o  Object file
   .a  Archive file

除非編譯過程出現(xiàn)錯誤,否則 "連結(jié)" 一定是產(chǎn)生一個新程序的最
   後階段。然而你也可以以 -c、-s 或 -E 等選項,將整個過程自四
   個階段中的其中一個停止。在連結(jié)階段,所有與原始碼相對應(yīng)的
   .o 文件、程序庫、和其他無法自文件名辨明屬性的文件(包括不以 .o
   為擴展名的 object file 以及擴展名為 .a 的 archive file)都會
   交由連結(jié)程序來處理(在指令行將那些文件當(dāng)作連結(jié)程序的參數(shù)傳給
   連結(jié)程序)。

選項:

   不同的選項必須分開來下:例如 `-dr' 這個選項就與 `-d -r' 大
   不相同。
   絕大部份的 `-f' 及 `-W' 選項都有正反兩種形式:-fname 及
   -fno-name (或 -Wname 及 -Wno-name)。以下只列出非預(yù)設(shè)的那個
   形式。
   以下是所有選項的摘要。以形式來分類。選項的意義將另辟小節(jié)說
   明。

   一般性(概略、常用的)選項
       -c -S -E -o file -pipe -v -x language

   程序語言選項
       -ansi -fall-virtual -fcond-mismatch
       -fdollars-in-identifiers -fenum-int-equiv
       -fexternal-templates -fno-asm -fno-builtin
       -fno-strict-prototype -fsigned-bitfields
       -fsigned-char -fthis-is-variable
       -funsigned-bitfields -funsigned-char
       -fwritable-strings -traditional -traditional-cpp
       -trigraphs

   編譯時的警告選項
       -fsyntax-only -pedantic -pedantic-errors -w -W
       -Wall -Waggregate-return -Wcast-align -Wcast-qual
       -Wchar-subscript -Wcomment -Wconversion
       -Wenum-clash -Werror -Wformat -Wid-clash-len
       -Wimplicit -Winline -Wmissing-prototypes
       -Wmissing-declarations -Wnested-externs -Wno-import
       -Wparentheses -Wpointer-arith -Wredundant-decls
       -Wreturn-type -Wshadow -Wstrict-prototypes -Wswitch
       -Wtemplate-debugging -Wtraditional -Wtrigraphs
       -Wuninitialized -Wunused -Wwrite-strings

   除錯選項
       -a -dletters -fpretend-float -g -glevel -gcoff
       -gxcoff -gxcoff+ -gdwarf -gdwarf+ -gstabs -gstabs+
       -ggdb -p -pg -save-temps -print-file-name=library
       -print-libgcc-file-name -print-prog-name=program

  最佳化選項
       -fcaller-saves -fcse-follow-jumps -fcse-skip-blocks
       -fdelayed-branch -felide-constructors
       -fexpensive-optimizations -ffast-math -ffloat-store
       -fforce-addr -fforce-mem -finline-functions
       -fkeep-inline-functions -fmemoize-lookups
       -fno-default-inline -fno-defer-pop
       -fno-function-cse -fno-inline -fno-peephole
       -fomit-frame-pointer -frerun-cse-after-loop
       -fschedule-insns -fschedule-insns2
       -fstrength-reduce -fthread-jumps -funroll-all-loops
       -funroll-loops -O -O2

   預(yù)處理選項
       -Aassertion -C -dD -dM -dN -Dmacro[=defn] -E -H
       -idirafter dir -include file -imacros file -iprefix
       file -iwithprefix dir -M -MD -MM -MMD -nostdinc -P
       -Umacro -undef

   匯編程序選項
       -Wa,option
   連結(jié)程序選項
       -llibrary -nostartfiles -nostdlib -static -shared
       -symbolic -Xlinker option -Wl,option -u symbol

  目錄選項
       -Bprefix -Idir -I- -Ldir

  Target Options
       -b machine -V version

  與機器(平臺)相關(guān)的選項
       M680x0 Options
       -m68000 -m68020 -m68020-40 -m68030 -m68040 -m68881
       -mbitfield -mc68000 -mc68020 -mfpa -mnobitfield
       -mrtd -mshort -msoft-float

VAX Options
       -mg -mgnu -munix

SPARC Options
       -mepilogue -mfpu -mhard-float -mno-fpu
       -mno-epilogue -msoft-float -msparclite -mv8
       -msupersparc -mcypress

Convex Options
       -margcount -mc1 -mc2 -mnoargcount

AMD29K Options
       -m29000 -m29050 -mbw -mdw -mkernel-registers
       -mlarge -mnbw -mnodw -msmall -mstack-check
       -muser-registers

M88K Options
       -m88000 -m88100 -m88110 -mbig-pic
       -mcheck-zero-division -mhandle-large-shift
       -midentify-revision -mno-check-zero-division
       -mno-ocs-debug-info -mno-ocs-frame-position
       -mno-optimize-arg-area -mno-serialize-volatile
       -mno-underscores -mocs-debug-info
       -mocs-frame-position -moptimize-arg-area
       -mserialize-volatile -mshort-data-num -msvr3 -msvr4
       -mtrap-large-shift -muse-div-instruction
       -mversion-03.00 -mwarn-passed-structs

  RS6000 Options
       -mfp-in-toc -mno-fop-in-toc

RT Options
       -mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs
       -mfull-fp-blocks -mhc-struct-return -min-line-mul
       -mminimum-fp-blocks -mnohc-struct-return

MIPS Options
       -mcpu=cpu type -mips2 -mips3 -mint64 -mlong64
       -mlonglong128 -mmips-as -mgas -mrnames -mno-rnames
       -mgpopt -mno-gpopt -mstats -mno-stats -mmemcpy
       -mno-memcpy -mno-mips-tfile -mmips-tfile
       -msoft-float -mhard-float -mabicalls -mno-abicalls
       -mhalf-pic -mno-half-pic -G num -nocpp

i386 Options
       -m486 -mno-486 -msoft-float -mno-fp-ret-in-387

HPPA Options
       -mpa-risc-1-0 -mpa-risc-1-1 -mkernel -mshared-libs
       -mno-shared-libs -mlong-calls -mdisable-fpregs
       -mdisable-indexing -mtrailing-colon

  i960 Options
       -mcpu-type -mnumerics -msoft-float
       -mleaf-procedures -mno-leaf-procedures -mtail-call
       -mno-tail-call -mcomplex-addr -mno-complex-addr
       -mcode-align -mno-code-align -mic-compat
       -mic2.0-compat -mic3.0-compat -masm-compat
       -mintel-asm -mstrict-align -mno-strict-align
       -mold-align -mno-old-align

  DEC Alpha Options
       -mfp-regs -mno-fp-regs -mno-soft-float -msoft-float

  System V Options
       -G -Qy -Qn -YP,paths -Ym,dir

  Code Generation Options
       -fcall-saved-reg -fcall-used-reg -ffixed-reg
       -finhibit-size-directive -fnonnull-objects
       -fno-common -fno-ident -fno-gnu-linker
       -fpcc-struct-return -fpic -fPIC
       -freg-struct-returno -fshared-data -fshort-enums
       -fshort-double -fvolatile -fvolatile-global
       -fverbose-asm

PRAGMAS
   Two `#pragma' directives are supported for GNU C++, to
   permit using the same header file for two purposes: as a
   definition of interfaces to a given object class, and as
   the full definition of the contents of that object class.

   #pragma interface
       (C++ only.) Use this directive in header files
       that define object classes, to save space in most
       of the object files that use those classes. Nor-
       mally, local copies of certain information (backup
       copies of inline member functions, debugging infor-
       mation, and the internal tables that implement vir-
       tual functions) must be kept in each object file
       that includes class definitions. You can use this
       pragma to avoid such duplication. When a header
       file containing `#pragma interface' is included in
       a compilation, this auxiliary information will not
       be generated (unless the main input source file it-
       self uses `#pragma implementation'). Instead, the
       object files will contain references to be resolved
       at link time.

   #pragma implementation

   #pragma implementation "objects.h"
       (C++ only.) Use this pragma in a main input file,
       when you want full output from included header
       files to be generated (and made globally visible).
       The included header file, in turn, should use
       `#pragma interface'. Backup copies of inline mem-
       ber functions, debugging information, and the in-
       ternal tables used to implement virtual functions
       are all generated in implementation files.

       If you use `#pragma implementation' with no argu-
       ment, it applies to an include file with the same
       basename as your source file; for example, in
       `allclass.cc', `#pragma implementation' by itself
       is equivalent  to  `#pragma  implementation
       "allclass.h"'. Use the string argument if you want
       a single implementation file to include code from
       multiple header files.

       There is no way to split up the contents of a sin-
       gle header file into multiple implementation files.

文件說明
   file.c       C source file
   file.h       C header (preprocessor) file
   file.i       經(jīng)預(yù)處理過的 C source file
   file.C       C++ source file
   file.cc      C++ source file
   file.cxx     C++ source file
   file.m       Objective-C source file
   file.s       assembly language file
   file.o       object file
   a.out       link edited output
   TMPDIR/cc*     temporary files
   LIBDIR/cpp     preprocessor
   LIBDIR/cc1     compiler for C
   LIBDIR/cc1plus   compiler for C++
   LIBDIR/collect   linker front end needed on some machines
   LIBDIR/libgcc.a  GCC subroutine library
   /lib/crt[01n].o  start-up routine
   LIBDIR/ccrt0  additional start-up routine for C++
   /lib/libc.a    standard C library, 參閱 man page intro(3)
   /usr/include  standard directory for #include files
   LIBDIR/include   standard gcc directory for #include files
   LIBDIR/g++-include additional g++ directory for #include

   LIBDIR is usually /usr/local/lib/machine/version.
   TMPDIR comes from the environment variable TMPDIR (default
   /usr/tmp if available, else /tmp).

gcc最佳編譯參數(shù)

摘要   本文著重介紹在不同的硬件環(huán)境下給GCC指定哪些參數(shù)才可以得到最佳的性能。   這篇文章是從一個名為Gentoo Linux的發(fā)行版的編程說明書里面分離出來的,希望對大家編譯程序有幫助。

--------------------------------------------------------------------------------
一、1.2版(gcc 2.9.x版)
i386 (Intel), do you really want to install gentoo on that? CHOST="i386-pc-linux-gnu" CFLAGS="-march=i386 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=i386 -O3 -pipe -fomit-frame-pointer"
i486 (Intel), do you really want to install gentoo on that? CHOST="i486-pc-linux-gnu" CFLAGS="-march=i486 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=i486 -O3 -pipe -fomit-frame-pointer"
Pentium, Pentium MMX+, Celeron (Mendocino) (Intel) CHOST="i586-pc-linux-gnu" CFLAGS="-march=pentium -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=pentium -O3 -pipe -fomit-frame-pointer"
Pentium Pro/II/III/4, Celeron (Coppermine), Celeron (Willamette?) (Intel) CHOST="i686-pc-linux-gnu" CFLAGS="-march=i686 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=i686 -O3 -pipe -fomit-frame-pointer"
Eden C3/Ezra (Via) CHOST="i586-pc-linux-gnu" CFLAGS="-march=i586 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=i586 -O3 -pipe -fomit-frame-pointer"
Quote : I did the original gentoo install using 1.2, with gcc 2.95 using -march=i586. i686 won't work.
K6 or beyond (AMD) CHOST="i586-pc-linux-gnu" CFLAGS="-march=k6 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=k6 -O3 -pipe -fomit-frame-pointer"
(A Duron will report "Athlon" in its /proc/cpuinfo)
Athlon (AMD) CHOST="i686-pc-linux-gnu" CFLAGS="-march=k6 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=k6 -O3 -pipe -fomit-frame-pointer"
For the following, i don't know of any flag that enhance performances..., do you ?
PowerPC CHOST="powerpc-unknown-linux-gnu" CFLAGS="-O3 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -pipe -fomit-frame-pointer"
Sparc CHOST="sparc-unknown-linux-gnu" CFLAGS="-O3 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -pipe -fomit-frame-pointer"
Sparc 64 CHOST="sparc64-unknown-linux-gnu" CFLAGS="-O3 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -pipe -fomit-frame-pointer"

二、1.4版(gcc 3.x版):
i386 (Intel), do you really want to install gentoo on that ? CHOST="i386-pc-linux-gnu" CFLAGS="-march=i386 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=i386 -O3 -pipe -fomit-frame-pointer"
i486 (Intel), do you really want to install gentoo on that ? CHOST="i486-pc-linux-gnu" CFLAGS="-march=i486 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=i486 -O3 -pipe -fomit-frame-pointer"
Pentium 1 (Intel) CHOST="i586-pc-linux-gnu" CFLAGS="-march=pentium -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=pentium -O3 -pipe -fomit-frame-pointer"
Pentium MMX (Intel) CHOST="i586-pc-linux-gnu" CFLAGS="-march=pentium-mmx -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=pentium-mmx -O3 -pipe -fomit-frame-pointer"
Pentium PRO (Intel) CHOST="i686-pc-linux-gnu" CFLAGS="-march=pentiumpro -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=pentiumpro -O3 -pipe -fomit-frame-pointer"
Pentium II (Intel) CHOST="i686-pc-linux-gnu" CFLAGS="-march=pentium2 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=pentium2 -O3 -pipe -fomit-frame-pointer"
Celeron (Mendocino), aka Celeron1 (Intel) CHOST="i686-pc-linux-gnu" CFLAGS="-march=pentium2 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=pentium2 -O3 -pipe -fomit-frame-pointer"
Pentium III (Intel) CHOST="i686-pc-linux-gnu" CFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer"
Celeron (Coppermine) aka Celeron2 (Intel) CHOST="i686-pc-linux-gnu" CFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer"
Celeron (Willamette?) (Intel) CHOST="i686-pc-linux-gnu" CFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer"
Pentium 4 (Intel) CHOST="i686-pc-linux-gnu" CFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer"
Eden C3/Ezra (Via) CHOST="i586-pc-linux-gnu" CFLAGS="-march=i586 -m3dnow -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=i586 -m3dnow -O3 -pipe -fomit-frame-pointer"
quote : the ezra doesn't have any special instructions that you could optimize for, just consider is a K6-3...basically a p2 with 3dnow
K6 (AMD) CHOST="i586-pc-linux-gnu" CFLAGS="-march=k6 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=k6 -O3 -pipe -fomit-frame-pointer"
K6-2 (AMD) CHOST="i586-pc-linux-gnu" CFLAGS="-march=k6-2 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=k6-2 -O3 -pipe -fomit-frame-pointer"
K6-3 (AMD) CHOST="i586-pc-linux-gnu" CFLAGS="-march=k6-3 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=k6-3 -O3 -pipe -fomit-frame-pointer"
Athlon (AMD) CHOST="i686-pc-linux-gnu" CFLAGS="-march=athlon -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=athlon -O3 -pipe -fomit-frame-pointer"
Athlon-tbird, aka K7 (AMD) CHOST="i686-pc-linux-gnu" CFLAGS="-march=athlon-tbird -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=athlon-tbird -O3 -pipe -fomit-frame-pointer"
Athlon-tbird XP (AMD) CHOST="i686-pc-linux-gnu" CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer"
Athlon 4(AMD) CHOST="i686-pc-linux-gnu" CFLAGS="-march=athlon-4 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=athlon-4 -O3 -pipe -fomit-frame-pointer"
Athlon XP (AMD) CHOST="i686-pc-linux-gnu" CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer"
Athlon MP (AMD) CHOST="i686-pc-linux-gnu" CFLAGS="-march=athlon-mp -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=athlon-mp -O3 -pipe -fomit-frame-pointer"
603 (PowerPC) CHOST="powerpc-unknown-linux-gnu" CFLAGS="-O3 -pipe -fomit-frame-pointer -fsigned-char" CXXFLAGS="-O3 -pipe -fomit-frame-pointer -fsigned-char"
603e (PowerPC) CHOST="powerpc-unknown-linux-gnu" CFLAGS="-O3 -pipe -fomit-frame-pointer -fsigned-char" CXXFLAGS="-O3 -pipe -fomit-frame-pointer -fsigned-char"
604 (PowerPC) CHOST="powerpc-unknown-linux-gnu" CFLAGS="-O3 -pipe -fomit-frame-pointer -fsigned-char" CXXFLAGS="-O3 -pipe -fomit-frame-pointer -fsigned-char"
604e (PowerPC) CHOST="powerpc-unknown-linux-gnu" CFLAGS="-O3 -pipe -fomit-frame-pointer -fsigned-char" CXXFLAGS="-O3 -pipe -fomit-frame-pointer -fsigned-char"
750 aka as G3 (PowerPC) CHOST="powerpc-unknown-linux-gnu" CFLAGS="-mcpu=750 -O3 -pipe -fomit-frame-pointer -fsigned-char" CXXFLAGS="-mcpu=750 -O3 -pipe -fomit-frame-pointer -fsigned-char"
Note: do not use -march=
7400, aka G4 (PowerPC) CHOST="powerpc-unknown-linux-gnu" CFLAGS="-mcpu=7400 -O3 -pipe -fomit-frame-pointer -fsigned-char -maltivec" CXXFLAGS="-mcpu=7400 -O3 -pipe -fomit-frame-pointer -fsigned-char -maltivec"
Note: do not use -march=
7450, aka G4 second generation (PowerPC) CHOST="powerpc-unknown-linux-gnu" CFLAGS="-mcpu=7450 -O3 -pipe -fomit-frame-pointer -fsigned-char -maltivec" CXXFLAGS="-mcpu=7450 -O3 -pipe -fomit-frame-pointer -fsigned-char -maltivec"
Note: do not use -march=
PowerPC (If you don't know which one) CHOST="powerpc-unknown-linux-gnu" CFLAGS="-O3 -pipe -fomit-frame-pointer -fsigned-char" CXXFLAGS="-O3 -pipe -fomit-frame-pointer -fsigned-char"
Sparc CHOST="sparc-unknown-linux-gnu" CFLAGS="-O3 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -pipe -fomit-frame-pointer"
Sparc 64 CHOST="sparc64-unknown-linux-gnu" CFLAGS="-O3 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -pipe -fomit-frame-pointer"GCC 使用指南 GCC 使用指南 GCC 使用指南





轉(zhuǎn)載自:http://blog.csdn.net/casularm/archive/2005/03/09/316143.aspx

- 作者: michaelbob 2005年03月20日, 星期日 13:55  回復(fù)(0) |  引用(0) 加入博采

zzGCC使用指南

創(chuàng)建時間:2000-06-08
文章屬性:轉(zhuǎn)載
文章提交: quack (quack_at_xfocus.org)


GCC使用指南

使用語法:
gcc [ option | filename ]...
g++ [ option | filename ]...

其中 option 為 gcc 使用時的選項(后面會再詳述),
而 filename 為欲以 gcc 處理的文件
說明:
這 C 與 C++ 的 compiler 已將產(chǎn)生新程序的相關(guān)程序整合起來。產(chǎn)
生一個新的程序需要經(jīng)過四個階段:預(yù)處理、編譯、匯編,連結(jié),
而這兩個編譯器都能將輸入的文件做不同階段的處理。雖然原始程序
的擴展名可用來分辨編寫原始程序碼所用的語言,但不同的 compiler
,其預(yù)設(shè)的處理程序卻各不相同:

gcc預(yù)設(shè)經(jīng)由預(yù)處理過(擴展名為.i)的文件為 C 語言,并於程
式連結(jié)階段以 C 的連結(jié)方式處理。

g++預(yù)設(shè)經(jīng)由預(yù)處理過(擴展名為.i)的文件為 C++ 語言,并於程

序連結(jié)階段以 C++ 的連結(jié)方式處理。


原始程序碼的擴展名指出所用編寫程序所用的語言,以及相對應(yīng)的處
理方法:

.cC 原始程序 ; 預(yù)處理、編譯、匯編
.CC++ 原始程序 ; 預(yù)處理、編譯、匯編
.cc C++ 原始程序 ; 預(yù)處理、編譯、匯編
.cxxC++ 原始程序 ; 預(yù)處理、編譯、匯編
.mObjective-C 原始程序 ; 預(yù)處理、編譯、匯編
.i已經(jīng)過預(yù)處理之 C 原始程序; 編譯、匯編
.ii 已經(jīng)過預(yù)處理之 C++ 原始程序; 編譯、匯編
.s組合語言原始程序 ; 匯編
.S組合語言原始程序 ; 預(yù)處理、匯編
.h預(yù)處理文件(標(biāo)頭文件) ; (不常出現(xiàn)在指令行)


其他擴展名的文件是由連結(jié)程序來處理,通常有:

.oObject file
.aArchive file


除非編譯過程出現(xiàn)錯誤,否則 "連結(jié)" 一定是產(chǎn)生一個新程序的最
後階段。然而你也可以以 -c、-s 或 -E 等選項,將整個過程自四
個階段中的其中一個停止。在連結(jié)階段,所有與原始碼相對應(yīng)的
.o 文件、程序庫、和其他無法自文件名辨明屬性的文件(包括不以 .o
為擴展名的 object file 以及擴展名為 .a 的 archive file)都會
交由連結(jié)程序來處理(在指令行將那些文件當(dāng)作連結(jié)程序的參數(shù)傳給
連結(jié)程序)。


選項:
不同的選項必須分開來下:例如 `-dr' 這個選項就與 `-d -r' 大
不相同。

絕大部份的 `-f' 及 `-W' 選項都有正反兩種形式:-fname 及
-fno-name (或 -Wname 及 -Wno-name)。以下只列出非預(yù)設(shè)的那個
形式。

以下是所有選項的摘要。以形式來分類。選項的意義將另辟小節(jié)說
明。

一般性(概略、常用的)選項
-c -S -E -o file -pipe -v -x language

程序語言選項
-ansi -fall-virtual -fcond-mismatch
-fdollars-in-identifiers -fenum-int-equiv
-fexternal-templates -fno-asm -fno-builtin
-fno-strict-prototype -fsigned-bitfields
-fsigned-char -fthis-is-variable
-funsigned-bitfields -funsigned-char
-fwritable-strings -traditional -traditional-cpp
-trigraphs

編譯時的警告選項
-fsyntax-only -pedantic -pedantic-errors -w -W
-Wall -Waggregate-return -Wcast-align -Wcast-qual
-Wchar-subscript -Wcomment -Wconversion
-Wenum-clash -Werror -Wformat -Wid-clash-len
-Wimplicit -Winline -Wmissing-prototypes
-Wmissing-declarations -Wnested-externs -Wno-import
-Wparentheses -Wpointer-arith -Wredundant-decls
-Wreturn-type -Wshadow -Wstrict-prototypes -Wswitch
-Wtemplate-debugging -Wtraditional -Wtrigraphs
-Wuninitialized -Wunused -Wwrite-strings

除錯選項
-a -dletters -fpretend-float -g -glevel -gcoff
-gxcoff -gxcoff+ -gdwarf -gdwarf+ -gstabs -gstabs+
-ggdb -p -pg -save-temps -print-file-name=library
-print-libgcc-file-name -print-prog-name=program

最佳化選項
-fcaller-saves -fcse-follow-jumps -fcse-skip-blocks
-fdelayed-branch -felide-constructors
-fexpensive-optimizations -ffast-math -ffloat-store
-fforce-addr -fforce-mem -finline-functions
-fkeep-inline-functions -fmemoize-lookups
-fno-default-inline -fno-defer-pop
-fno-function-cse -fno-inline -fno-peephole
-fomit-frame-pointer -frerun-cse-after-loop
-fschedule-insns -fschedule-insns2
-fstrength-reduce -fthread-jumps -funroll-all-loops
-funroll-loops -O -O2

預(yù)處理選項
-Aassertion -C -dD -dM -dN -Dmacro[=defn] -E -H
-idirafter dir -include file -imacros file -iprefix
file -iwithprefix dir -M -MD -MM -MMD -nostdinc -P
-Umacro -undef

匯編程序選項
-Wa,option

連結(jié)程序選項
-llibrary -nostartfiles -nostdlib -static -shared
-symbolic -Xlinker option -Wl,option -u symbol

目錄選項
-Bprefix -Idir -I- -Ldir

Target Options
-bmachine -V version

與機器(平臺)相關(guān)的選項
M680x0 Options
-m68000 -m68020 -m68020-40 -m68030 -m68040 -m68881
-mbitfield -mc68000 -mc68020 -mfpa -mnobitfield
-mrtd -mshort -msoft-float

VAX Options
-mg -mgnu -munix

SPARC Options
-mepilogue -mfpu -mhard-float -mno-fpu
-mno-epilogue -msoft-float -msparclite -mv8
-msupersparc -mcypress

Convex Options
-margcount -mc1 -mc2 -mnoargcount

AMD29K Options
-m29000 -m29050 -mbw -mdw -mkernel-registers
-mlarge -mnbw -mnodw -msmall -mstack-check
-muser-registers

M88K Options
-m88000 -m88100 -m88110 -mbig-pic
-mcheck-zero-division -mhandle-large-shift
-midentify-revision -mno-check-zero-division
-mno-ocs-debug-info -mno-ocs-frame-position
-mno-optimize-arg-area -mno-serialize-volatile
-mno-underscores -mocs-debug-info
-mocs-frame-position -moptimize-arg-area
-mserialize-volatile -mshort-data-num -msvr3 -msvr4
-mtrap-large-shift -muse-div-instruction
-mversion-03.00 -mwarn-passed-structs

RS6000 Options
-mfp-in-toc -mno-fop-in-toc

RT Options
-mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs
-mfull-fp-blocks -mhc-struct-return -min-line-mul
-mminimum-fp-blocks -mnohc-struct-return

MIPS Options
-mcpu=cpu type -mips2 -mips3 -mint64 -mlong64
-mlonglong128 -mmips-as -mgas -mrnames -mno-rnames
-mgpopt -mno-gpopt -mstats -mno-stats -mmemcpy
-mno-memcpy -mno-mips-tfile -mmips-tfile
-msoft-float -mhard-float -mabicalls -mno-abicalls
-mhalf-pic -mno-half-pic -G num -nocpp

i386 Options
-m486 -mno-486 -msoft-float -mno-fp-ret-in-387

HPPA Options
-mpa-risc-1-0 -mpa-risc-1-1 -mkernel -mshared-libs
-mno-shared-libs -mlong-calls -mdisable-fpregs
-mdisable-indexing -mtrailing-colon

i960 Options
-mcpu-type -mnumerics -msoft-float
-mleaf-procedures -mno-leaf-procedures -mtail-call
-mno-tail-call -mcomplex-addr -mno-complex-addr
-mcode-align -mno-code-align -mic-compat
-mic2.0-compat -mic3.0-compat -masm-compat
-mintel-asm -mstrict-align -mno-strict-align
-mold-align -mno-old-align

DEC Alpha Options
-mfp-regs -mno-fp-regs -mno-soft-float -msoft-float

System V Options
-G -Qy -Qn -YP,paths -Ym,dir

Code Generation Options
-fcall-saved-reg -fcall-used-reg -ffixed-reg
-finhibit-size-directive -fnonnull-objects
-fno-common -fno-ident -fno-gnu-linker
-fpcc-struct-return -fpic -fPIC
-freg-struct-returno -fshared-data -fshort-enums
-fshort-double -fvolatile -fvolatile-global
-fverbose-asm

PRAGMAS
Two`#pragma'directivesaresupported for GNU C++, to
permit using the same header file for two purposes:asa
definitionofinterfaces to a given object class, and as
the full definition of the contents of that objectclass.

#pragma interface
(C++only.) Usethisdirective in header files
that define object classes, to save spaceinmost
oftheobject files that use those classes.Nor-
mally, local copies of certain information(backup
copies of inline member functions, debugging infor-
mation, and the internal tables that implement vir-
tualfunctions)mustbe kept in each object file
that includes class definitions.You can usethis
pragmatoavoidsuch duplication.When a header
file containing `#pragma interface' is includedin
acompilation, this auxiliary information will not
be generated (unless the main input source file it-
selfuses `#pragma implementation').Instead, the
object files will contain references to be resolved
at link time.

#pragma implementation

#pragma implementation "objects.h"
(C++only.)Use this pragma in a main input file,
when you wantfulloutputfromincludedheader
filesto be generated (and made globally visible).
The includedheaderfile,inturn,shoulduse
`#pragmainterface'.Backup copies of inline mem-
ber functions, debugging information, andthein-
ternaltablesused to implement virtual functions
are all generated in implementation files.

If you use `#pragma implementation' withnoargu-
ment,itapplies to an include file with the same
basename asyoursourcefile;forexample,in
`allclass.cc',`#pragmaimplementation' by itself
is equivalentto`#pragmaimplementation
"allclass.h"'.Use the string argument if you want
a single implementation file to includecodefrom
multiple header files.

Thereis no way to split up the contents of a sin-
gle header file into multiple implementation files.

文件說明
file.c C source file
file.h C header (preprocessor) file
file.i 經(jīng)預(yù)處理過的 C source file
file.C C++ source file
file.ccC++ source file
file.cxx C++ source file
file.m Objective-C source file
file.s assembly language file
file.o object file
a.outlink edited output
TMPDIR/cc* temporary files
LIBDIR/cpp preprocessor
LIBDIR/cc1 compiler for C
LIBDIR/cc1plus compiler for C++
LIBDIR/collect linker front end needed on some machines
LIBDIR/libgcc.aGCC subroutine library
/lib/crt[01n].ostart-up routine
LIBDIR/ccrt0 additional start-up routine for C++
/lib/libc.astandard C library, 參閱 man page intro(3)
/usr/include standard directory for #include files
LIBDIR/include standard gcc directory for #include files
LIBDIR/g++-include additional g++ directory for #include

LIBDIR is usually /usr/local/lib/machine/version.
TMPDIR comes from the environment variable TMPDIR (default
/usr/tmp if available, else /tmp).

gcc


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 五月天中文在线 | 94在线成人免费视频 | 国产电影网 | 亚洲欧美日韩中文综合在线不卡 | 高清国产一区二区三区四区五区 | 国产人成午夜免视频网站 | 亚洲无毛 | 一区亚洲 | 亚洲精品久久久一区二区三区 | 日韩在线精品 | 亚洲国产中文字幕 | 一个人看aaaa免费中文 | 欧美爽爽爽爽爽爽视频 | 免费观看国产大片资源视频 | 日韩三 | 欧美日韩福利视频 | 起视碰碰97摸摸碰碰视频 | 日本在线观看视频网站 | 亚洲成人二区 | 日韩在线视频在线观看 | 国产精品果冻麻豆精东天美 | 偷拍小美女洗澡在线播放 | 成人情趣视频 | 成人视品 | 小宝与康熙粤语 | 久久日本精品国产精品白 | 我爱看片(永久免费) | 久操中文在线 | 日日摸夜夜添夜夜添破第一 | 欧美一级黄视频 | 深夜毛片 | 日韩欧美精品 | 婷婷综合缴情亚洲五月伊 | 亚洲一级在线 | 精品一区二区久久久久久久网站 | 国产在线精品一区二区 | 日韩一区二区精品视频 | 无码国产精品成人午夜视频 | 国产成人一区二区精品非洲 | 九九热线精品视频6一 | 国产网站在线播放 |