GCC, G++, static library, dynamic library

GCC compiler

  1. Regardless of gcc or g++, C programs can be compiled, and the rules and parameters of compiling programs are the same;
  2. g++ can directly compile C++ programs, gcc compiles C++ programs need to add additional parameters -lstdc++
  3. Either gcc or g++ can define __cplusplus

In actual use:

# 使用gcc指令编译C代码
#只用g++指令编译C++代码
#例如:
g++ test.cpp -o test

compilation process

  1. Preprocessing-Pre-Processing //.i file
# -E 选项指示编译器仅对输入文件进行预处理
g++ -E test.cpp -o test.i      //i文件
  1. Compile-Compilling //.s file
# -s 编译选项告诉g++在为c++代码产生了汇编语言文件后停止编译

Guess you like

Origin blog.csdn.net/weixin_41837701/article/details/125076786