有没有办法在MacBook M1上安装和使用GCC?
我正在尝试在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的(现在较老)的讨论是在我的CPUFUN博客上:设置Apple M1从命令行中进行本机代码开发
简短版本
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
brew
to install the relevant native compilers, but make sure that you have added the correct (/opt/homebrew/...
) path to yourPATH
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 thePATH
, rather than adding to it...Remember that there are a number of useful commands to help you diagnose problems like this:-
which
commandto 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 namegcc
alone, but rather installgcc-11
(or whatever), so you you may need to do that explicitly.