2012-07-28

GCC 編譯參數

2012-07-27 - R.J' Wiki : GCC 編譯參數
  • 使用方式(Usage)
    gcc [options] file..
  • 選項參數(option)
    • -c : 只做編譯(不做連結)
    • -S : 輸出組譯碼
    • -E : 將預處理結果顯示
    • -o filename : 指定輸出檔名
    • -ansi : 程式要求依據ansi c標準
    • -Dmacro : 使定義巨集(marco)為有效
    • -Dmarco=defn : 使定義巨集(marco)為defn
    • -Wa,option : 將選項(option)傳給組譯器
    • -wl,option : 將選項(option)傳給連結器
    • -I : 追加include檔案的搜尋路徑
    • -L : 追加library檔案的搜尋路徑
    • -l : 指定連結的函式庫
    • -Wall : 顯示所有的警告訊息
    • -g : 編入除錯資訊(要使用GDB除錯一定要加)
    • -O2 : 做最佳化
  • 範例(Example)
    gcc -o file a1.c a2.c a3.c
    gcc -Wall -g test1.c -o test1
    gcc -Iinclude -Llibrary -lmy_lib test2.c -o test2
    gcc -DDEBUG_ON test3.c -o test3
    gcc -c test.c -o test4
    

主頁 : http://gcc.gnu.org/

沒有留言: