GCC
支持了许多不同的语言,包括 C、C++、Ada、Fortran、Objective C,Perl、Python 和
Ruby,甚至还有 Java。
Linux
内核和许多其他自由软件以及开放源码应用程序都是用 C 语言编写并使用
GCC 编译的。
编译 C++程序:
-c 只编译不连接
g++ file1 -c -o file1.o
g++ file2 -c -o file2.o
g++ file1.o file.o -o exec
g++ -c a.cpp 编译
g++ -o a a.o 生成可执行文件
也可以 g++ -o a a.cpp 直接生成可执行文件。
1. 编译单个源文件
“
为了进行测试,你可以创建 Hello World”程序:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
printf(“Hello world!n”);
exit(0);
}
使用如下命令编译并测试这个代码:
# gcc -o hello hello.c