Mac OS X Lion 上的 GNU GCC 4.6(.1) 编译器
对于这种开发来说相当新鲜。想知道是否有人能指出我正确的方向。据我所知,使用 MacPorts 会出现无法运行的错误。然而,我在四处阅读时看到了这个: http://beardedcodewarrior.net/2011/07/25/building-gcc-4-6-1-on-mac-os-x-lion/但是仍然无法让它工作。当我执行 make for gcc 时,花了 3 个多小时才完成,然后一旦我执行 sudo make install,它就成功完成了,但是当我尝试 gcc --version 时,它仍然显示 gcc 版本 4.2.1(基于 Apple Inc. 构建) 5658)(LLVM 版本 2335.15.00)。我需要4.6.1版本!
Pretty new to this kind of development. Wondering if anyone can point me in the right direction. As far as I can see it, 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
存在三种可能的可能性:
$PATH
中比之前安装的 GCC 更早的目录,但 Bash 的内部哈希表条目仍然指向旧的 GCC。$PATH
中的目录比之前安装的 GCC 晚。gcc
。如果#1,只需运行命令
hash -r
并重试。为了避免频繁的$PATH
查找,Bash 使用哈希表将可执行文件名称映射到可执行文件位置。当您在$PATH
中较早安装的新可执行文件与$PATH
中较晚的可执行文件同名时,Bash 并不知道这一点。运行hash -r
表示“清除哈希表”。或者,您可以运行hash -d gcc
来表示“忘记哈希表中的 gcc”。如果#2,那么您需要通过其全名来执行 gcc(例如
/opt/local/bin/gcc
),或者修改您的$PATH
以便目录包含新 gcc 的目录早于现有 gcc 的目录。假设您正常安装了 MacPorts,那么这应该已经为您完成了 — MacPorts 将/opt/local/bin
放在$PATH
中,而不是/usr/bin< /code> 通过修改您的
~/.bash_profile
启动文件。如果#3,则找出可执行文件的名称。几乎可以肯定它的名称以 gcc 为前缀,因此如果您输入 gcc 然后按两次 Tab 键,Bash 将为您提供所有以 gcc 开头的命令的列表。它很可能被命名为
gcc-4.6
或gcc-mp-4.6
。There are three likely possibilities:
$PATH
than your previous GCC installation, but Bash's internal hash table entry is still pointing to the old GCC.$PATH
than your previous GCC installation.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. Runninghash -r
says "clear out your hash table". Alternatively, you can just runhash -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
orgcc-mp-4.6
.