1

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?

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

2 Answers 2

1

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.

1
  • 1
    sudo apt-get install --reinstall libgcc-4.8-dev is enough, see my answer.
    – A.B.
    Jul 26, 2015 at 9:24
0

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

Therefore

sudo apt-get install --reinstall libgcc-4.8-dev
1
  • Yes, it looks like that was it
    – kos
    Jul 26, 2015 at 9:25

You must log in to answer this question.

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