C++编译过程

2022/2/27 20:21:22

本文主要是介绍C++编译过程,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

test.cpp (预编译器: 头文件copy 宏替换等)> test.i (编译器)> test.s(汇编文件) (汇编器)> test.obj/test.o(目标文件) (链接器)> test.exe/test(可执行文件)

  • test.cpp
#include <iostream>
#define PI 3.1415926

int main(int argc, char* argv[])
{
  std::cout << "PI is: " << PI << std::endl;
  return 0;
}
  • 预编译
g++ -E test.cpp -o test.i
  • 编译
g++ -S test.i -o test.s
  • 汇编
g++ -C test.s -o test.o
  • 可执行文件
g++ test.s -o test
file test


这篇关于C++编译过程的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程