Hello,
In this week’s feature highlight, we look at How to Install GCC on Ubuntu 22.10
The default Ubuntu repositories contain a meta-package named “build-essential” that includes the GNU compiler collection, GNU debugger, and other development libraries and tools required for compiling software.
Update System
apt update
Install the GCC package dependencies.
apt install build-essential
To check GCC version
gcc --version
Output:
root@crown:~# gcc --version
gcc (Ubuntu 12.2.0-3ubuntu1) 12.2.0
Copyright (C) 2022 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.
That’s it. GCC tools and libraries have been installed on your Ubuntu system.
Compiling a Hello World Example
Compiling a basic C or C++ program using GCC is pretty easy. For example let’s create a hello world C program. Save the following code as hello.c
text file:
nano hello.c
// hello.c
#include <stdio.h>
int main() {
printf("Hello, world!\n");
return 0;
}
Save the file and compile it into an executable:
$ gcc -o hello hello.c
$ ./hello
Hello, world!
Done.