问题
Since early today I have not been able to compile any C programs in Eclipse as it will not create the necessary binaries when I build a project, in fact it won't create a binaries folder at all. I have tried everything I've seen on here to try to fix it, and it's only gotten worse. Here's what I've tried so far and the results:
From "Launch Failed. Binary Not Found." Snow Leopard and Eclipse C/C++ IDE issue, in Terminal:
cd /usr/bin
sudo rm cc gcc c++ g++
sudo ln -s gcc-4.0 cc
sudo ln -s gcc-4.0 gcc
sudo ln -s c++-4.0 c++
sudo ln -s g++-4.0 g++
This was supposed to change the path to 32-bit GCC 4.0 from 64-bit 4.2. After doing this however, I had a major problem: I no longer had any type of GCC as evidenced by the fact that when I called
gcc -v
in Terminal, it returned:
-bash: gcc: command not found
In an attempt to make things right, I re-downloaded the Command Line Tools from Xcode and reinstalled them, and Xcode acknowledges that they are indeed installed. Despite this, calling gcc -v still returned -bash: gcc: command not found. After repeating this process, I got the same result, which makes it seem as if I cannot install/find the c compiler at all! It also seems that the binaries for previous C projects that worked when everything was fine disappeared after doing this.
I also tried:
Going to Project > Properties > C/C++ Build > Settings > Binary Parsers : and making sure Mach-O 64 Parser was selected.
Editing in the Miscellaneous sections of MacOS X C Linker and GCC C Compiler the flags textbox to hold "-arch i686"
None of this worked...
I am now at a loss and really stuck. If anyone can help, it would be greatly appreciated.
Thank you!
回答1:
First thing's first: Have you read/tried the most-upvoted answer on the linked question about Ctrl-click to select "Build Project"?
I can't really speak to your issue with Eclipse, as I don't use it, but I suspect that you've probably mucked up your OS X installation at this point. Unfortunately, the advice you used may have been helpful in the SnowLeopard timeframe, but it's most likely not any more. I'm not sure exactly when this happened, but GCC 4.0 is no longer shipping with OS X or Xcode and it's certainly gone as of 10.9.2. It won't be installed any more by either Xcode, or by the "Install Command Line Tools" option, so if you really need that specific version of the compiler, you're going to have to build and install it yourself.
By default, on recent OS X installs, the compiler executables in /usr/bin
are stubs that effectively call xcrun
to determine the location of Xcode's current version. By default /usr/bin/gcc
points to whatever version of clang
came with your currently-installed version of Xcode.
I'm not sure how to get those stubs back after deleting them, but I would start by doing a fresh install of the latest Xcode and then doing Install Command Line Tools again after that, and see if that gets you back to at least having these stubs in place.
Beyond that, I would look for another approach to your problem with Eclipse. Clang is certainly capable of generating 32-bit binaries. I can't think of a good reason that you would want to use GCC 4.0 over clang at all.
来源:https://stackoverflow.com/questions/22522286/launch-failed-binary-not-found-error-for-c-in-eclipse-4-3-0-on-os-x-10-9-2