有没有办法在MacBook M1上安装和使用GCC?

发布于 2025-02-10 11:06:20 字数 383 浏览 2 评论 0原文

我正在尝试在MacBook M1上安装并与GCC编译器合作。我已经使用自家酿造的GCC安装了GCC,但是我找不到在Mac中的终端上使用它的方法。我想下载一种使用GCC编译器进行安装的工具。具体而言,看起来该工具需要OpenMP,而Clang不支持它。

错误消息运行命令时:

clang: error: unsupported option '-fopenmp'

当我更改通往GCC安装路径的路径时,我无法在终端中运行基本命令。我知道这是这样做的原因。有人可以帮忙吗?

I am trying to install and work with gcc compiler on my MacBook M1. I have installed gcc using home-brew, but I did not find a way to use it on the terminal in my Mac. I wanted to download a tool that uses gcc compiler for its installation. Specifically, it looks like the tool needs OpenMP and clang does not support it.

Error message when I run make command:

clang: error: unsupported option '-fopenmp'

When I change the path to the gcc installation path, I am unable to run basic commands like ls in the terminal. I understand that this is the reason for that. Could anyone please help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

身边 2025-02-17 11:06:20

我的(现在较老)的讨论是在我的CPUFUN博客上:设置Apple M1从命令行中进行本机代码开发

简短版本

  1. 在运行X86_64编译外壳时, 非常小心。 (您不想!)
  2. 使用brew安装相关的本机编译器,但请确保您添加了正确的(/opt/opt/homebrew/.... )通往路径环境的路径。 Homebrew 3.0.0发行说明。)

(请参阅 有关您如何更改路径的信息,不可能说出您的情况有什么问题,但是听起来好像您只是仅将单个目录分配给path,而不是加上它...

请记住,有许多有用的命令可以帮助您诊断这样的问题: -

  • wher 命令
    告诉你命令来自哪里。

  • - 版本向编译器标记以显示它们是哪个编译器。

  • brew可能不会单独使用名称gcc的链接,而是安装gcc-11(或其他),因此您可能需要明确执行此操作。

My (now rather old) discussion of this is on my CpuFun blog: Setting up the Apple M1 for Native Code Development from the Command Line

The short version is

  1. Be very careful about running X86_64 compiled shells. (You don't want to!)
  2. Use brew to install the relevant native compilers, but make sure that you have added the correct (/opt/homebrew/...) path to your PATH envirable. (See the Homebrew 3.0.0 release notes.)

Without more information about how you changed your PATH it's impossible to say what is wrong in your case, but it does sound as if you simply assigned a single directory to the PATH, rather than adding to it...

Remember that there are a number of useful commands to help you diagnose problems like this:-

  • which command
    to tell you where command is coming from.

  • The --version flag to the compilers to show which compiler they are.

  • brew may not make a link for the name gcc alone, but rather install gcc-11 (or whatever), so you you may need to do that explicitly.

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