I installed build-essential in Ubuntu 14.04 and created a test file helloworld.c with:

#include <stdio.h>
int main(void)
{ printf("Hello world\n"); return 0; } 

The output of gcc -o hello helloworld.c is:

/usr/lib/gcc/i686-linux-gnu/4.8/libgcc.a: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status

Are there any suggestions for what I've done wrongly?

  • 2
    This question is not off-topic, it's about compilation and doesn't involve programming at all. – kos Jul 26 '15 at 9:27

I found the problem. There was an old, corrupt installation of gcc-4.8, which doesn't get replaced when build-essential is installed. I used

sudo apt-get remove gcc-4.8
sudo apt-get remove --purge
sudo apt-get auto-remove
sudo apt-get install build-essential

Now the test runs fine.

| improve this answer | |
  • 1
    sudo apt-get install --reinstall libgcc-4.8-dev is enough, see my answer. – A.B. Jul 26 '15 at 9:24

My two cents:

The file with the name /usr/lib/gcc/i686-linux-gnu/4.8/libgcc.a is part of the package libgcc-4.8-dev


sudo apt-get install --reinstall libgcc-4.8-dev
| improve this answer | |
  • Yes, it looks like that was it – kos Jul 26 '15 at 9:25

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.