I am trying to install GCC from source. I am following the instructions on the wiki at https://gcc.gnu.org/wiki/InstallingGCC and also on this question on SO. I am running into issues on the configure step when running:

$PWD/../gcc-4.6.2/configure --prefix=$HOME/gcc-4.6.2

I get the following output and error:

checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking for libatomic support... yes
checking for libcilkrts support... no
checking for libitm support... yes
checking for libsanitizer support... yes
checking for libvtv support... yes
checking for libmpx support... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/bin/objdir':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

I appears as if the error is because there is no C compiler installed. This confuses me because isn't installing a C compiler what installing GCC is supposed to do? All the solutions I can find for this error say that I need to install GCC, so how can I install GCC if I need GCC installed to do it?

I have updated my $PATH variable using export PATH=$PATH:/usr/bin/gcc-4.6.2 but it didn't help. I have also looked at this similar question without success: https://unix.stackexchange.com/questions/310669/c-compiler-while-installing-gcc

Is there something I am missing? What else can I do to get GCC installed?

NOTE: I can't just use yum or apt-get to install it because I am using a custom distribution that does not have those type of installer software installed.

  • The source code to GCC still needs to be compiled by something, like yacc or some other compiler. Otherwise you're asking how a dictionary can possibly make any sense, what with it using words to define words that are themselves defined by words which are all defined within the dictionary that you can't use if you don't know any words to begin with.
    – DopeGhoti
    Jul 12, 2017 at 20:41
  • 1
    @dopeghoti: yacc is not a c compiler
    – rici
    Jul 12, 2017 at 22:48
  • Could have sworn it was Yet Another C Compiler. I stand corrected.
    – DopeGhoti
    Jul 12, 2017 at 22:49

2 Answers 2


GCC itself is written in C. Thus, in order to install it, you need a C compiler. This is a catch-22. You're not missing anything. In fact, there is a rather famous Ken Thompson essay, “Reflections on Trusting Trust” reflecting upon a related aspect.

You need to get a C compiler from somewhere. Whoever built your custom distribution surely had one, as you can't build a Linux kernel without it either. They ought to make it available somewhere.

Other than that, you'll have to cross-compile gcc (and binutils, and C library headers, etc.) from a distro where you can install a compiler. This is how someone builds the a distro for a new platform. It's also possible that if your platform is embedded, no one expects you to run gcc on the device itself, and instead they expect you to cross-compile any software you need for the device. In that case, your embedded distro should provide the cross-compiler to use.

  • Interesting...I am using a Raspberry Pi, so maybe I will need to cross-compile. I do not have experience with cross-compiling so I will have to look into that. Any idea which dir on my distro a C compiler might be located? Also if I understand your comment correctly, since the reason I wanted to install GCC was so I could use it during the installation of a different piece of software I could just forget about installing GCC and use cross-compiling to install the other software that I need. Is that correct? Jul 12, 2017 at 21:07
  • @GeraldMurphy which distro is this? If it's not in /usr/bin, it's probably not installed—but it might be an optional thing you can download and install (e.g., by using tar). Other software needs to support cross-compiling. Some do, some don't... The RPi is powerful enough to run a C compiler, and you can (e.g., Raspbian has one). So I'd attempt installing a compiler on the Pi first.
    – derobert
    Jul 12, 2017 at 21:13
  • I am using a Yocto distribution. I don't see anything that looks like a C compiler under /usr/bin/ (I am assuming it would be called something like 'C' 'compile' or 'gcc' but I am not sure.). I will see if I can find a tar for a C compiler. Jul 12, 2017 at 21:27

I had this exact issue while working with a Ubuntu subsystem within Windows 10 and solved it by doing:

sudo apt-get update 
sudo apt install build-essential

Alternatively, the second command could be more specific:

sudo apt install gcc

Not the answer you're looking for? Browse other questions tagged or ask your own question.