How to Install GCC (C and C++ Compiler) on Fedora

Take Your Linux Skills to the Next Level All courses, certifications, ad-free articles & community — from $8/mo
Join Root →
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Access to Linux certifications (RHCSA, RHCE, LFCS and LFCA)
Access new courses on release
Get access to weekly newsletter
Priority help in comments
Private Telegram community
Connect with the Linux community
From $8/mo · or $59/yr billed annually · Cancel anytime

Fedora is a modern Linux distribution that provides a stable and powerful environment for development using a tool called C compiler, which is used to compile C programs into executable files.

In Fedora, the C compiler tool is part of a package called gcc (GNU Compiler Collection), and this article will guide you through the steps to install gcc and get started with compiling C programs on Fedora.

Installing GCC (C and C++ Compiler) on Fedora

Before installing any new software, it’s a good practice to update your existing system software packages to the latest available security updates.

sudo dnf update

Next, install gcc, which is a part of development tools that includes gcc and other essential tools like make, gdb, and git.

sudo dnf groupinstall "Development Tools"
Install Development Tools in Fedora
Install Development Tools in Fedora

After the installation is complete, you should verify that gcc is correctly installed and available on your system.

gcc --version
Check GCC Vesrion
Check GCC Version

Writing a Simple C Program in Fedora

To test if gcc is working properly, you can write a simple C program by creating a hello.c file.

nano hello.c
OR
vi hello.c

In the editor, write the following C program:

#include <stdio.h>

int main() {
    printf("Hello, World!\n");
    return 0;
}

Now that you have written a simple C program, you need to compile it using the gcc command to create an executable file named hello.

gcc hello.c -o hello

Once the compilation is successful, you can run the executable file to see the output of your C program.

./hello
Run C Program in Fedora
Run C Program in Fedora

To learn more about how to use gcc, you can refer to the official GCC documentation or use the man command to view the manual page:

man gcc

For more advanced C programming, you might need additional libraries and tools based on the requirements of your development projects.

sudo dnf install glibc-devel   [GNU C Library]
sudo dnf install libm          [Math Library]
sudo dnf install gdb           [Debugging Tool]

Uninstalling GCC (C and C++ Compiler) on Fedora

If you ever need to remove gcc from your system, you can uninstall it using the following command:

sudo dnf remove gcc

If you installed the entire “Development Tools” group and want to remove it, you can use:

sudo dnf groupremove "Development Tools"
Conclusion

You have now successfully installed the C compiler with needed development tools on Fedora and learned how to compile and run a simple C program.

Root Plan
Premium Linux Education for Serious Learners

Take Your Linux Skills to the Next Level

Root members get full access to every course, certification prep track, and a growing library of hands-on Linux content — with new courses added every month.

What You Get
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Access to Linux certifications (RHCSA, RHCE, LFCS and LFCA)
Access new courses on release
Get access to weekly newsletter
Priority help in comments
Private Telegram community
Connect with the Linux community
Ravi Saive
I'm Ravi Saive, an award-winning entrepreneur and founder of several successful 5-figure online businesses, including TecMint.com, GeeksMint.com, UbuntuMint.com, and the premium learning hub Pro.Tecmint.com.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

2 Comments

Leave a Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Root Plan Premium Linux Education for Serious Learners

Before You Go - Upgrade Your Linux Skills

Root members get everything in one place, with new courses added every month.

What You Get
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Linux certifications: RHCSA, RHCE, LFCS and LFCA
Access new courses on release
Weekly newsletter, priority support & Telegram community
Join Root Today and Start Learning Linux the Right Way
Structured courses, certification prep, and a community of Linux professionals - all in one membership.
Join Root Plan →
$8/mo · or $59/yr billed annually