1. 程式人生 > >C++ 的編譯過程

C++ 的編譯過程

一個 compiler produces ati and pro 鏈接 files 匯編語言

Recall that g++ is not actually the C++ compiler – it is a driver program that hides a lot of the complexity of the compilation process from us. What is actually going on here is:

  • The C++ preprocessor is called to handle things like #include.
  • Preprocessed text is passed to the actual C++ compiler, which produces compiled assembly language code.
  • The assembly language code is assembled by the GCC assembler, producing an object code file.
  • The object code file is linked with the C++ libraries by the linker to produce the final executable.
  • The intermediate files are disposed of.

  • 調用 C++ 預處理器來處理 #include 等問題。
  • 預處理的文本傳遞給實際的 C++ 編譯器, 它生成編譯的匯編語言代碼。
  • 匯編語言代碼由 GCC 匯編程序組裝, 生成一個對象代碼文件。
  • 鏈接器將對象代碼文件與 C++ 庫鏈接, 以生成最終可執行文件。
  • 中間文件被釋放。

C++ 的編譯過程