1

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:

  1. Going to Project > Properties > C/C++ Build > Settings > Binary Parsers : and making sure Mach-O 64 Parser was selected.

  2. 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!

Community
  • 1
  • 1
Jonathan O'Farrell
  • 327
  • 1
  • 2
  • 12

1 Answers1

0

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.

ipmcc
  • 29,581
  • 5
  • 84
  • 147
  • When you say that I've might've mucked up my installation, do you mean that I might have to reinstall OS X 10.9.2? Are you also saying that GCC is no longer installed with the command line tools in 10.9.2 and Xcode 5.1? Sorry, I'm pretty new with this and so am quite lost – Jonathan O'Farrell Apr 02 '14 at 00:54
  • This command `sudo rm cc gcc c++ g++` will have deleted the stub executables that were there. I would hope that reinstalling Command Line Tools would be sufficient to bring them back, but I'm not sure off the top of my head. – ipmcc Apr 02 '14 at 10:41
  • Unfortunately I've tried reinstalling the command line tools and even all of Xcode itself but have had no success. I've been reading that Apple may have dumped gcc in favor of clang, but I am not sure. I was able to get clang to compile one program in Eclipse yesterday, but am not sure how to set it to the default compiler for all C programs... – Jonathan O'Farrell Apr 03 '14 at 16:34
  • Oh GCC is gone for sure from recent OSX developer tools, but there are little stubs that execute clang when you invoke the command `gcc` (`cc` is just a symlink to clang) so that fewer things break. – ipmcc Apr 03 '14 at 19:29
  • Interesting! Unfortunately no matter what I do it does not appear that the link to clang is occurring as whenever I invoke 'gcc' I get an error saying that there is no such command as 'gcc', but I will try to figure out how to repair this soon! Thank you! – Jonathan O'Farrell Apr 04 '14 at 06:01