REPOST: Why -bash: /usr/bin/g++: cannot execute binary file?

Ryan Schmidt ryandesign at macports.org
Tue Dec 14 13:45:03 PST 2010


On Dec 14, 2010, at 09:09, Gabriele Kahlout wrote:

> http://stackoverflow.com/questions/4435805/why-bash-usr-bin-g-cannot-execute-binary-file

As was said in one of the comments there, it sounds like your Xcode is not installed properly, and you should reinstall it.

As was said there, /usr/bin/g++ should be a symlink to the actual compiler. Here's what that looks like on my computer:

$ ls -l /usr/bin/g++*
lrwxr-xr-x  1 root  wheel       7 Nov 30 03:50 /usr/bin/g++ -> g++-4.2
-rwxr-xr-x  1 root  wheel   97392 Jul 21 07:19 /usr/bin/g++-4.0
-rwxr-xr-x  1 root  wheel  166128 Jun 24 12:22 /usr/bin/g++-4.2


But you showed that on your computer you have:

$ ls -l /usr/bin/g++
-rwxrwxrwx@ 1 simpatico wheel 103368 13 Dez 22:56 /usr/bin/g++


So clearly that's not a symlink to anything, but a complete binary program -- and apparently one that doesn't work for you. So reinstall Xcode to replace this and any other wrong files with the right ones. The latest version of Xcode for Snow Leopard is currently 3.2.5, so if you were working with an earlier version, update to the latest.


You also asked in that thread how you verify that a file is of the right architecture. The answer is to use the "lipo -info" command to see what architectures the program was compiled for, and to know what architectures your computer can run. For example, on my system:

$ lipo -info /usr/bin/g++
Architectures in the fat file: /usr/bin/g++ are: i386 ppc7400 x86_64 


And I know that my machine runs x86_64 and i386 code natively, and ppc code via Rosetta emulation, so any of those architectures are fine for me.




More information about the macports-users mailing list