Why does a Linux distribution have gcc installed in advance? Is it because most of the applications in linux are written in C?

What would happen if the gcc directory is deleted?

  • 15
    "Linux" doesn't have gcc installed in advance. gcc is part of certain installation configurations of certain distributions. gcc and dozens of programs you never have heard of (and never used). Commented Jun 29, 2013 at 11:05
  • 1
    so can a linux distribution work perfectly without a c compiler?
    – DesirePRG
    Commented Jun 29, 2013 at 11:07
  • In general, yes. There are (or were) closed source programs though which are very low level and thus need to adapt to the kernel version by compiling some glue code. I have experienced that with VMware. But if you don't need those then your installation should work without gcc. Commented Jun 29, 2013 at 11:10
  • 4
    It's generally not installed has been my observation. If you do an installation where the option is to "install everything" then of course it'll be installed. But when I do "server" installs of different distros, it's typically not there. Even "desktop" installs don't have in general. If you select "developer desktop" then you get it.
    – slm
    Commented Jun 29, 2013 at 11:53

4 Answers 4


Why does a Linux distribution have gcc installed in advance?

A Linux distribution is rather vague. Some install it, most offer to install it (possibly even if you select the defaults during installation). However not all distributions will install it and you usually have a choice.

Is it because most of the applications in Linux are written in C?

No. A C-compiler (any C-compiler, GCC is just an example, it might just as well be clang/lvm, or something else) is just incredibly handy to have. And not just on a Linux system, but also on BSDs or windows installations.

What would happen if the gcc directory is deleted?

Assuming their are no programs installed which depend on any part of GCC (or an a part of it, such as the pre-processor) then everything will continue to work just fine. You just can not compile any new C programs with that GCC version you just deleted. If it was the last C-compiler (you can have multiple compilers installed) then you will need to use a binary package to reinstall it if you to compile any C programs later.

Note that with What would happen if the gcc directory is deleted? I assume you would delete it using the proper package manager. Just randomly deleting directories on any OS is not a safe thing to do.

  • 3
    Also, as far as I remember, POSIX requires a working C compiler to be available in a POSIX-compliant system. So, if a distribution wants to be as close as possible to POSIX, it needs a C compiler.
    – liori
    Commented Jun 29, 2013 at 15:55
  • 1
    And many programs are distributed only in source form or for different platforms, with the user expected to compile them to work on their particular system. Not "most", but still a lot.
    – Wutaz
    Commented Jun 29, 2013 at 17:39
  • I wouldn't say that a C compiler comes in handy on Windows. Programs are usually distributed as installers or precompiled binaries, the user is not supposed to compile anything. On Unix this is completely different, of course.
    – Malcolm
    Commented Jun 29, 2013 at 21:20
  • 2
    @liori AFAIR, a C compiler is part of the (C) development option in all versions of POSIX. You don't need one to claim POSIX conformance, only to claim conformance with that option. Commented Jun 29, 2013 at 23:11
  • dkms requires gcc and you need dkmsif you have external kernel modules (VirtualBox, virus scanner, specific hardware...) so they can be recompiled to work with your kernel updates.
    – xenoid
    Commented Dec 11, 2017 at 0:01

A number of utilities on Linux have been compiled using gcc. Most of those utilities make calls to run-time shared library and in case you uninstall the total package, you will still need to keep the shared libraries.

I did a little search on /bin/ls using the command strings -a /bin/ls and it shows the use of libc.so which is the standard C library on Linux. Since Linux is officially Gnu/Linux, I can assume that most of the utilities have been compiled with Gnu/C or gcc. If you do man libc, you will notice that it indicates the use of glibc for most of the Linux utilities. Hence, you need to keep libc and glibc for the utilities to work.

  • 1
    This answer would IMO be greatly improved by listing a few examples of applications which make such calls to GCC and its related toolchain and libraries after the applications have been built. Other than closed-source applications needing glue code to be updated e.g. when installing a new kernel version as mentioned by Hauke in the comments to the question, I can't think of any use case for that not related to software development (in which case you'd almost certainly want a compiler anyway, though of course it wouldn't necessarily have to be GCC in particular).
    – user
    Commented Jun 29, 2013 at 19:11
  • 1
    The shared library is libgcc_s, which is typically provided separately from gcc. Commented Jun 29, 2013 at 23:13

Lack of ABI compatibility especially in the past means that building from source is pretty common. Of course, many need more than just a C compiler to build too...


On name-brand servers (HP Enterprises Proliant, Fujitsu Primergy, and others) the vendor-specific hardware monitoring drivers will often come in a form that includes some source code for the essential kernel interface components. The driver packages will usually also include pre-compiled drivers for any supported kernel versions known to the hardware vendor at the time the driver package was released.

That way, whenever a Linux distribution publishes a kernel security update, the hardware monitoring modules can be recompiled to match the updated kernel, without the need to wait for the hardware vendor to test and publish new packages to match the updated kernel.

Usually the monitoring drivers include some script automation that will automatically recompile the appropriate modules the first time the system is booted with a new kernel version. Of course this will be successful only if the compiler and the necessary kernel development/header package are installed on the system.

If this wasn't done, there might be times where installing a critical security upgrade would cost you much of your basic hardware monitoring information: the status of system PSUs, temperatures, fans and on modern servers usually power consumption too.

In datacenters, such monitoring can make the difference between "Oh, a redundant fan/PSU has died, I'll send the datacenter guy to hot-swap it during office hours tomorrow" and "The server had lost too many fans, started to overheat and shut itself down. Now a SLA is broken and the customer is unhappy - the server needs to be fixed or replaced ASAP at oh-dark-thirty." (Yes, not everything is cloud-based or even virtualized yet.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .