Mac OS X Lion 上的 GNU GCC 4.6(.1) 编译器

发布于 2024-12-03 07:35:56 字数 441 浏览 2 评论 0原文

对于这种开发来说相当新鲜。想知道是否有人能指出我正确的方向。据我所知,使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪是无色的血 2024-12-10 07:35:56

存在三种可能的可能性:

  1. 它安装正确,并进入 $PATH 中比之前安装的 GCC 更早的目录,但 Bash 的内部哈希表条目仍然指向旧的 GCC。
  2. 它安装正确,但进入 $PATH 中的目录比之前安装的 GCC 晚。
  3. 安装正确,但可执行文件未命名为 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.6gcc-mp-4.6

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文