4.2. Downloading GCC
To begin with, let’s utilize the wget command to download the source code as a .tar archive from the official GCC website:
$ wget http://ftp.gnu.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.gz
or you go to the gcc website to check for new version of gcc and change a .tar archive accordingly.
http://ftp.gnu.org/gnu/gcc/
In the above link, we used 14.2.0 as the version to download since it’s the current latest version available for GCC.
After that, we use the tar command to extract the contents from the .tar archive to the current directory:
$ tar -xf gcc-14.2.0.tar.gz
Here, the -x option, short for –extract, extracts the contents from the archive and the -f option, short for –file, specifies the archive that contains the files to extract.
After extraction, a new subdirectory with the contents from the .tar archive appears in the working directory.
4.3. Preparing for Installation
Let’s navigate to the new subdirectory:
$ cd gcc-14.2.0
Then, we use the ./configure command to get the system ready for the installation:
$ ./configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-14.2.0 --enable-checking=release \
--enable-languages=c,c++ --disable-multilib --program-suffix=-14.2.0
Command completed successfully.
The last line suggests that the machine is ready for the installation.
4.4. Installing GCC
The final step is to build and install GCC on the system.
So, let’s build it by running the make command:
$ make
Finally, we install GCC on the machine:
$ sudo make install
After completion, we should have the utility successfully installed on the system.
Let’s perform a version check to verify the installation:
$******/gcc-14.2.0/bin/gcc-14.2.0 --version
gcc-14.2.0 (GCC) 14.2.0
Visibly, the latest version is now installed on the machine.
5. Conclusion
In this article, we’ve provided a detailed explanation of three methods that we can use to install GCC on Ubuntu.
By following any of these methods, we can seamlessly integrate GCC with a Ubuntu system and start compiling code.
Comments
Post a Comment