在Ubuntu系统中,可以通过以下步骤来检查GCC(GNU编译器集合)是否安装成功:
打开终端:
Ctrl + Alt + T
打开终端。输入命令检查GCC版本:
gcc --version
gcc (Ubuntu 10.2.0-13ubuntu1) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
创建一个C源文件:
nano
或 vim
)创建一个新的C文件,例如 test.c
:nano test.c
#include <stdio.h>
int main() {
printf("Hello, GCC!\n");
return 0;
}
nano
中按 Ctrl + O
保存,然后按 Ctrl + X
退出)。编译C程序:
gcc test.c -o test
运行生成的可执行文件:
./test
Hello, GCC!
which gcc
/usr/bin/gcc
通过以上方法,你可以确认GCC是否在Ubuntu系统中成功安装并可以正常使用。