在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程序:
hello.c 的文件:echo '#include<stdio.h>\nint main() { printf("Hello, World!\\n"); return 0; }' > hello.c
编译程序:
hello.c 文件:gcc hello.c -o hello
hello 的可执行文件。运行程序:
./hello
Hello, World!
更新包列表:
sudo apt update
检查GCC是否已安装:
dpkg -l | grep gcc
通过以上方法,你可以确认GCC是否在Ubuntu系统中成功安装。如果未安装,可以使用以下命令来安装GCC:
sudo apt install gcc
希望这些步骤能帮助你解决问题!