I'm trying to install gcc 4.8.1 at the moment. Currently 4.8.2 and 4.9.1 are installed. I downloaded an 4.8.1 from here http://gcc.cybermirror.org/releases/gcc-4.8.1/ . After extracting the files I did a ./configure and then tried make. At the end of make, I get this error

/usr/include/linux/errno.h:1:23: fatal error: asm/errno.h: No such file or directory
 #include <asm/errno.h>

I am new to linux so I do not know how to find or add this header file.

Edit: Steps I made:

  1. Extract gcc-4.8.1.tar.gz to a folder
  2. Open terminal window
  3. cd gcc-4.8.1
  4. ./configure --build=x86_64-linux-gnu
  5. make -j4

I don't know what I did differently but it finally compiled. After that I did make install. My question now how do I use this instead of 4.8.2 which using the command gcc-4.8 still defaults to.

  • Please tell me you did not do sudo make install. It's highly recommended when building stuff from source that you use --prefix flag (and with GCC, the --program-suffix flag) while configuring. Since you haven't, try running /usr/bin/gcc. – muru Sep 29 '14 at 23:46
  • @muru Thank you so much for your help! I have managed to use 4.8.1 now. I didn't realize I needed to purge 4.8.2 first. Also, I did use sudo make install. Is there a reason not to? – Meenor Sep 30 '14 at 1:14
  • Well, you configured GCC without giving a suffix. So while /usr/bin/gcc should normally be handled by Ubuntu's package system, it has now been overwritten by the one you compiled. – muru Sep 30 '14 at 13:04

The asm/errno.h header is provided by a variety of packages. Odd that gcc would require it, but you can try:

sudo apt-get install linux-libc-dev

You also need to tell GCC to look for an architecture and OS specific location for the headers:

../configure --build=x86_64-linux-gnu 

(or i386-linux-gnu for 32-bit Ubuntu).

It's highly recommended when building stuff from source that you use --prefix flag (and with GCC, the --program-suffix flag) while configuring. Since you haven't, try running /usr/bin/gcc.


tar xf gcc-4.8.1.tar.gz 
mkdir gcc
cd gcc
../gcc-4.8.1/configure  --build=x86_64-linux-gnu --prefix=/usr/local --program-suffix=-4.8.1
make -j
sudo make install

Now your GCC binaries will be installed to /usr/local/bin/, and other things in other folders in /usr/local.

For example:

$ /usr/local/bin/gcc-4.8.1  # or simply gcc-4.8.1, since this folder is in your PATH

Note how I'm running configure and make from a different directory, outside of where the GCC source is? That's how the GCC docs recommend that GCC be built.

  • Hi I just tried installing that but it said it was already installed. – Meenor Sep 29 '14 at 19:39
  • Sorry, I'm not sure how to specify those. Could you give me an example of how I would go about doing that? – Meenor Sep 29 '14 at 19:46
  • Do you have linux-headers installed? – chili555 Sep 29 '14 at 20:14
  • muru, I tried that but I'm still getting the same error. – Meenor Sep 29 '14 at 20:44
  • @muru, Yeah I did use make clean. I also tried deleting the folder, reextracting the files and repeating the steps. No success. – Meenor Sep 29 '14 at 20:49

I got the same error on ubuntu-xenial 4.4.0-75-generic.

I found I had a /usr/include/asm-generic folder, but no /usr/include/asm, which gcc was looking for.

Creating a symlink solved it for me.

sudo ln -s /usr/include/asm-generic/ /usr/include/asm

Fair warning: Although, sometimes, one has to do this kind of trickery, it's not always a good idea just because it works. I'm doing this in a virtual machine, which I can recreate by running a simple script, and that is why it's no big deal if I break something.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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