GCC 代表 GNU Compiler Collections,主要用于编译 C 和 C++ 语言。它还可以用于编译 Objective C 和 Objective C++。编译源代码文件时需要的最重要的选项是源程序的名称,其余每个参数都是可选的,如警告、调试、链接库、目标文件等。 GCC 命令的不同选项允许用户停止不同阶段的编译过程。
g++ 命令是 GNU c++ 编译器调用命令,用于源代码的预处理、编译、汇编和链接以生成可执行文件。 g++ 命令的不同“选项”允许我们在中间阶段停止这个过程。
g++ 和 gcc 之间的区别
g++ | gcc |
---|---|
g++ is used to compile C++ program. | gcc is used to compile C program. |
g++ can compile any .c or .cpp files but they will be treated as C++ files only. | gcc can compile any .c or .cpp files but they will be treated as C and C++ respectively. |
Command to compile C++ program through g++ is g++ fileName.cpp -o binary |
command to compile C program through gcc is gcc fileName.c -o binary |
Using g++ to link the object files, files automatically links in the std C++ libraries. | gcc does not do this. |
g++ compiles with more predefined macros. | gcc compiles C++ files with more number of predefined macros. Some of them are #define __GXX_WEAK__ 1, #define __cplusplus 1, #define __DEPRECATED 1, etc |