Hi!
I use Linux Mint Maya and I need to install some software from sources but the problem is that GCC is not working.
When I type gcc or make command I get a error like this:

bash: /usr/bin/gcc: cannot execute binary file

How can I fix that?

Recommended Answers

All 9 Replies

Open up a terminal and try the following commands:
file /usr/bin/gcc
and:
ldd /usr/bin/gcc
What output do they produce?

Also is your system 32 bit or 64 bit?

I have a feeling that you may be running a 32 bit version of gcc on a 64 bit machine, at least I think that's what usually causes this error!

If this is the case, then you probably need to install the gcc-multilib package:
sudo apt-get install gcc-multilib

If this doesn't fix the problem, you might also need the ia32-libs package, which allows you to run 32 bit apps on a 64 bit OS. Again, use sudo apt-get install ia32-libs

Hope this is of some help!

I installed gcc-multilib and ia32-libs but it's still not working.
My system is 32 bit.
This is the output of the commands after I have installed the packages you said:
file /usr/bin/gcc
/usr/bin/gcc: symbolic link to gcc-4.6
and
ldd /usr/bin/gcc

/usr/bin/ldd: line 161: /lib64/ld-linux-x86-64.so.2: cannot execute binary file
    not a dynamic executable

Before installing the packages the ldd /usr/bin/gcc command returned only this:
not a dynamic executable

Oops! You were supposed to run the 'file' and 'ldd' commands before doing anything to see what they said! Never mind, my bad! Looks I didn't explain myself clearly. I meant for you to run the two commands first and see what output they gave you. I suspected you were running 32 bit executables on a 64 bit machine. The output of both of those commands would have confirmed this if it was the case!

And if it did turn out to be the problem, that was when you should have installed the two packages. But that's a moot point now because you said that you are running a 32 bit system, so it looks like I was completely wrong. Sorry about that!

So those packages aren't going to help at all... you'll probably want to uninstall both of them using sudo apt-get remove ia32-libs gcc-multilib. Perhaps followed up with sudo apt-get autoremove to remove any unused/orphaned packages that the two removed packages depended on (if there are any!).

That should get you back to where you were before.
Once you've removed those two packages, try running the 'file' and 'ldd' commands on /usr/bin/gcc and see what it says. It might yield some clue as to what's going on!

I'm not sure what to suggest.....Perhaps purge gcc and reinstall it?
sudo apt-get purge gcc && sudo apt-get install gcc
Actually, hold off on doing that for now. I'll take a look at my Kubuntu install and investigate what files are used by gcc....

Hmmmm.....Looking at my own 32 bit Kubuntu install (which should be similar to your mint setup), I get the same error that you posted when I use the file and ldd commands on /usr/bin/gcc.

However, I can see that /usr/bin/gcc is a symbolic link to /usr/bin/builder-cc, which in turn is a Perl script. (I found that out using the command ls -alh /usr/bin/gcc and ls -alh /usr/bin/builder-cc)

So that's why we saw the 'not a dynamic executable' error message, because gcc itself is not an executable file, it's a shortcut to a Perl script! Who knew?!

Taking a look at the Perl script /usr/bin/builder-cc using the less command (less /usr/bin/builder-cc), I can see it uses different environment variables to determine which version of gcc to use when gcc is called.

If you type the command ls -alh /usr/bin/gcc* it will show you all of the files in /usr/bin that start with gcc.

In my case, I have gcc (which we've already determined is a sym-link to the Perl script builder-cc ), gcc-4.6, gcc-4.7 and gcc.real. (I also have gccgo and gccgo-4.7, but these aren't relevant. These are part of the compiler for GNU implementation of Googles 'Go' programming language)

Anyway, analysing the gcc files:
In the results from the ls command, I can see that gcc.real is a symbolic link to /usr/bin/gcc-4.6, which is the actual executable for version 4.6 of the gcc compiler. And gcc-4.7 is the executable for version 4.7 of the gcc compiler.

So gcc-4.6 is the default version of gcc on my machine and I also have gcc-4.7.

The file command shows that /usr/bin/gcc-4.6 and /usr/bin/gcc-4.7 are both dynamically linked 32 bit builds of gcc. And the ldd command shows that both link with linux-gate.so.1, libc.so.6 and /lib/ld-linux.so.2

So, perhaps take a look at the gcc files that you have in /usr/bin and work out which ones are the actual gcc executables. Then try running the 'file' and 'ldd' commands on those to see what output is given before deciding what to do next!

Well, I've learnt something new! I always assumed that gcc was the gcc executable itself...Hmmm! Who knew?! Anyway yes, examine the gcc files that are in /usr/bin and identify which ones are the actual executables, then take a look at what information 'file' and 'ldd' give you!

Ok! In /usr/bin I have gcc-4.6.
The 'file' command returns:
gcc-4.6: data
and the 'ldd' command returns:
/usr/bin/ldd: line 161: /lib64/ld-linux-x86-64.so.2: cannot execute binary file not a dynamic executable
Searching in system information I found this: systeminfo

In fact when I try to use a 'make' command I get a error like this: no compiler support

That's strange, so it's saying that you have gcc v4.6, but you aren't able to use it.
In fact file says that the gcc file you have is data and not an executable....hmm..
And according to your system information you don't have a default compiler installed.....

Have you installed the build-essential package yet? When you said gcc wasn't working I assumed that you at least had gcc installed, but now I'm thinking you don't have it at all....
I recommend installing build-essential with the command: sudo apt-get install build-essential
That would be my first suggestion. That package provides all of the packages you'll need to be able to compile from source(including gcc).

Hopefully that should solve your problem!

build-esential was already installed. I reinstalled it but still not work.
I tried to run g++ and it works.
I have no idea what happened to gcc.
I need to compile a kernel module and I'm not able because of that.

build-esential was already installed. I reinstalled it but still not work.

Make sure that you purge it before reinstalling:

$ sudo apt-get remove --purge build-essential
$ sudo apt-get install build-essential

Other than that, your problem is a real mystery to me. You might have a better chance on a Linux Mint forum or bug reporting system.

As Mike2K said... You have a 32-bit system, but have somehow installed 64-bit versions of gcc and related cruft. You need to remove them all from the system and then reinstall the 32-bit versions of gcc et al.

Hi!
I managed to solve this problem.
I installed a .deb file called gcc-4.6_4.6.3-1ubuntu5_i386 and now gcc works fine.
I have no idea why with apt-get didn't work.
Thank you for all replies!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.