开发者

GNU GCC 4.6(.1) compiler on Mac OS X Lion

Pretty new to this kind of development. Wondering if anyone can point me in the right direction. As far as I can see it开发者_如何学JAVA, using MacPorts has an error where it doesn't work. However, I was reading around and saw this: http://beardedcodewarrior.net/2011/07/25/building-gcc-4-6-1-on-mac-os-x-lion/ but still couldn't get it to work. When I executed make for gcc, it took over 3 hours to complete and then once I execute sudo make install, it completed successfully but when I try gcc --version, it still says gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00). I need the 4.6.1 version!


There are three likely possibilities:

  1. It installed correctly and went into a directory earlier in your $PATH than your previous GCC installation, but Bash's internal hash table entry is still pointing to the old GCC.
  2. It installed correctly but went into a directory later in your $PATH than your previous GCC installation.
  3. In installed correctly, but the executable is not named gcc.

If #1, just run the command hash -r and try again. In order to avoid frequent $PATH lookups, Bash uses a hash table to map executable names into executable locations. When you install a new executable earlier in your $PATH with the same name as one later in the $PATH, Bash doesn't know about it. Running hash -r says "clear out your hash table". Alternatively, you can just run hash -d gcc to say "forget about gcc in your hash table".

If #2, then you either need to execute gcc by its full name (e.g. /opt/local/bin/gcc), or modify your $PATH so that the directory containing the new gcc is earlier than the directory of your existing gcc. Assuming you installed MacPorts normally, that should already be done for you—MacPorts puts /opt/local/bin earlier in your $PATH than /usr/bin by modifying your ~/.bash_profile startup file.

If #3, then figure out what name the executable was given. It was almost certainly given a name prefixed with gcc, so if you type gcc and then hit the tab key twice, Bash will give you a list of all of the commands that begin with gcc. It's quite likely it was given a name likw gcc-4.6 or gcc-mp-4.6.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜