GNU/Linux Fedora 35 Installing GCC 12.2 from Source – QuickStart Guide
[xyz-ihs snippet=”336AdTop”]Hi! This tutorial will guide you step-by-step on How to Install GNU Compiler Collection 12.2.x from Source in Fedora 35 GNU/Linux.
And the GCC 12.2 for Fedora 35 is a Compilers Collection currently supporting C, C++, Objective-C, Objective-C++, Fortran, Ada, D, Go, and BRIG (HSAIL) Languages.
Finally, GCC 12.2 includes several New Features, Changes, and Fixes that you can consult on the GNU GCC Documentation.
![Step-by-step GCC 12.2 Fedora 35 Installation Guide - Featured](https://tutorialforlinux.com/wp-content/media/dg139/intro/gnomePenguinLoveGnu.jpg)
1. Launching Terminal
Open a Shell Session
(Press “Enter” to Execute Commands)
2. Querying System GCC
First, find out what the actual System GCC
Play:which gcc
Take Note of the PATH to use after installation for switching the System GCC.
Possibly to Check the current GCC version issue:gcc -v
3. Downloading GCC 12.2
Download GCC 12.2 Source Code for GNU/Linux
Navigate to the 12.2.x Folder to Grab the Package.4. Extracting GCC 12.2
Then to Extract GCC 12.2 Archive
If it does Not Open automatically then Double-Click/Right-Click to Open with Archive Manager:Or from Command Line:
tar xvzf ~/Downloads/gcc-12.*.tar.gz
(But if downloaded with Firefox it may be instead into /tmp/mozilla*)
Finally, if you are in Trouble to Find Out it on Terminal See: How to Access Downloads Folder from Browser.
5. Installing Dependencies
Now to Install Required Dependencies
Now install the Dependency Package with Multilib support with:sudo dnf group install "C Development Tools and Libraries"
And again:sudo dnf install ncurses-devel bison flex openssl-devel elfutils-libelf-devel glibc-devel libstdc++-devel glibc-devel.i686 libstdc++-devel.i686
Then access the Target Directory:cd ~/Downloads/gcc-12.*/
And again to Download the Required Libraries play:./contrib/download_prerequisites
6. Setting up Environment
Next Set Libraries Env Variable
Eventually to Check the Target run:find /usr/ -name crti*
Then Output should be as:/usr/lib64/crti.o
So in this case then to Set up the Environment Variables use:export LIBRARY_PATH=/usr/lib64
And then amend the User’s Path to append the New shared Libraries:echo "export LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:/usr/local/lib64" >> ~/.bashrc
Last, to reload it:bash
7. Installing GCC 12.2
Finally, to Install GCC 12.2 on Fedora 35
First, make a Build Directory:mkdir build
Then entry it:cd build
Configuring with:../configure --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix="/usr/local"
Possibly customize the “languages” choiches in the above Command. To enable ADA and D Support see the Official Documentation.
And then making it:make -j $(nproc)
This Command to make it quicker using Multiples CPU Cores.
Now take a long Time Out because the Build process will run for a while…
Last, to make the Installation:sudo make install
8. Switching System GCC
(Optional) Finally, to easy Managing GCC Versions use Alternatives
The New GCC relase should be Automatically Set as Default over the Installation.
So now to Set System for to manage a Multi Compiler.
Add the System GCC with alternatives playing:sudo alternatives --install /usr/lib64/ccache/gcc gcc /usr/bin/x86_64-redhat-linux-gcc 20
Next to Switch between GCC Versions play:sudo alternatives --config gcc
Last, to test the GCC in use:gcc -v
![Step-by-step GCC 12.2 Fedora 35 Installation Guide - alternatives GCC](https://tutorialforlinux.com/wp-content/media/dg139/terminal/updateAlternatives-configGcc10.png)
Congratulations, your GCC 12.2 should be now nicely working on Fedora 35. Good Luck! :)