Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I used debootstrap to set up a minimal Debian system (x86):

debootstrap wheezy /var/chroot http://ftp.debian.org/debian/

Then I entered the chroot and installed some packages:

apt-get install build-essential m4 flex bison libgmp-dev libmpfr-dev

I'm trying to build gcc 4.1.3 (don't ask why). I configured it as follows:

./configure --prefix=/usr/local --program-suffix=-4.1.3 --enable-languages=c,c++

It ran for a few minutes, and then it failed with errors like:

In file included from /usr/include/stdio.h:28,
                 from ../.././gcc/tsystem.h:90,
                 from ../.././gcc/crtstuff.c:68:
/usr/include/features.h:323:26: error: bits/predefs.h: No such file or directory
/usr/include/features.h:356:25: error: sys/cdefs.h: No such file or directory
/usr/include/features.h:388:23: error: gnu/stubs.h: No such file or directory
In file included from ../.././gcc/tsystem.h:90,
                 from ../.././gcc/crtstuff.c:68:
/usr/include/stdio.h:36:25: error: bits/types.h: No such file or directory
In file included from ../.././gcc/tsystem.h:90,
                 from ../.././gcc/crtstuff.c:68:

However, I have no trouble building a small program that uses stdio.h. So I can compile stuff, but not gcc, apparently.

What additional installation/configuration has to be done to the chroot in order to make it possible to build gcc?

share|improve this question
This missing files are in libc6-dev. But it should already be installed (build-essential depends on it). Do you use the same architecture in your chroot as on the host system? – jofel Jul 5 '14 at 15:03
This looks like a perfect duplicate of Building GCC inside a chroot from source but I'm not sure that the answer there will help you. Please let me know if it does and I'll close as a dupe. – terdon Jul 5 '14 at 15:07
@jofel: Yes, the host system is 32-bit Debian. – Brian Bi Jul 5 '14 at 15:09

I was able to complete the build after setting:

export LIBRARY_PATH=/usr/lib/i386-linux-gnu
export C_INCLUDE_PATH=/usr/include/i386-linux-gnu
export CPLUS_INCLUDE_PATH=/usr/include/i386-linux-gnu

Edit: I realize now the source of the problem. The gcc that comes with the system knows to search in directories such as /usr/include/i386-linux-gnu. However, the gcc that I build doesn't search in those directories. Consequently the build fails at stage2.

It seems that gcc doesn't have any configuration options that let you set the header and library search paths, so I'm guessing that gcc-4.1 is just too old (before the advent of the Debian multiarch scheme) and newer versions all know already to search in /usr/include/<target> and so on.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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