3

on my new macbook pro with osx lion and XCode 4.1 I have some problems with gcc.

In /usr/bin I cannot find gcc-4.2

I only have the following versions:

i686-apple-darwin11-llvm-gcc-4.2 llvm-gcc llvm-gcc-4.2 

As a result when I try to select gcc42 by means of port select --set gcc gcc42 it returns me the following error: Selecting 'gcc42' for 'gcc' failed: could not create new link "/opt/local/bin/gcc": target "/usr/bin/gcc-4.2" doesn't exist

However port select gcc returns me the following versions:

apple-gcc42 gcc42 llvm-gcc42 (active) mp-gcc44 

How can I fix this problem?

Thanks!

6 Answers 6

7

I could manage to solve this issue in Mountain Lion with a symbolic link:

sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2 

Hope this help someone

Sign up to request clarification or add additional context in comments.

Comments

6

There should be a /usr/bin/gcc-4.2 with Xcode 4.1 installed. However, with the recent Xcode 4.2 update, Apple has finally removed their modified standard gcc-4.2. What remains is either llvm-gcc42 (also symlinked to gcc) and clang, the newer non-gcc C compiler. Apple is making the transition to clang; the first step is using the hybrid llvm-gcc42. There have been some reported problems using either of the new compilers. You should be using this time to figure out if you have problems with them and, if so, fix your code and report bugs to Apple. In the meantime, if you absolutely have to have the old gcc-4.2, it is possible to build one similar to the previous Apple-modified one via MacPorts:

port install apple-gcc42 

but you'll be swimming against the tide.

3 Comments

Thanks! I already installed gcc44 from macport and I can select it through sudo port select -set gcc mp-gcc44. However I cannot find it in /usr/bin/.
Ok, I found it in /opt/loca/bin/ Actually the problem is that the software I'm compiling look for /usr/bin/gcc42 IF(${CMAKE_SYSTEM} MATCHES "Darwin-11.*")
MacPorts never installs anything to /usr/bin; that is managed exclusively by Apple as part of OS X. Is it possible to override the compiler selection with a CC environment variable or some such?
5

With Xcode 4.3, you need to install the Command Line Tools separately. XCode -> Preferences -> Downloads, Click the Components button, and then click Install next to the "Command Line Tools" option.

Comments

2

I had the same issue.

I fixed it by doing a symlink.

Like this :

cd /usr/bin 

then :

sudo ln -s llvm-gcc-4.2 gcc-4.2 

Comments

0

You might consider compiling a newer GCC (e.g. 4.6.2) from its source code. Apple does not care much any more about GCC, but GCC has made significant progress since 4.2

And you probably could use your llvm-gcc42 as a GCC compiler.

Comments

0

I tampered with the innards of the makefile and found out that one invoked option provided an argument too many; replaced the variable with the actual result of the function called on my machine (removing the excess argument) and did run make again it worked.

1 Comment

What option? Care to show what changes you performed to the makefile?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.