在Mac上更新制作版本4.1

Ale*_*lex 8 c++ macos makefile

我正在尝试更新我的mac上的make版本,但遇到了问题.最小的项目依赖是4.1,但我的版本似乎是3.81.我已经将Xcode更新到最新版本并安装了命令行工具,但它似乎仍然是旧版本.

有没有人遇到这个问题或知道解决它的方法?

小智 18

首先,当前版本:

$ make --version                  
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Run Code Online (Sandbox Code Playgroud)

安装/配置步骤:

$ make --version                  
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Run Code Online (Sandbox Code Playgroud)

结果:

$ make -v
GNU Make 4.3
Built for x86_64-apple-darwin19.6.0
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Run Code Online (Sandbox Code Playgroud)

  • @AntonBelousov 它不起作用的原因是因为此答案中指定的“导出路径”不正确。您必须运行“brew info make”才能查看它建议的路径。另请参阅 /sf/answers/5007602141/ 答案,因为它具有正确的“导出” (3认同)

Pat*_*ick 15

这是我做的,它适用于我的MacOS:

步骤1:安装自制软件(安装命令来自https://brew.sh/):

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Run Code Online (Sandbox Code Playgroud)

第2步:使用自制软件来安装make

brew install make --with-default-names
Run Code Online (Sandbox Code Playgroud)

只是因为它不起作用,试试这个:

brew install homebrew/dupes/make --with-default-names
Run Code Online (Sandbox Code Playgroud)

步骤3:您需要更改默认命令以使用正确的make而不是MacBook或Mac中的默认值.

例如,如果您键入

make --version
Run Code Online (Sandbox Code Playgroud)

你会看见:

GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Run Code Online (Sandbox Code Playgroud)

哪个是默认版本的默认路径.

所以,现在,在.bash_profile(应该在你的主目录/ Users/your_name下),添加以下行:

export PATH="/usr/local/bin:$PATH"
Run Code Online (Sandbox Code Playgroud)

然后找到你的.bash_profile.现在尝试检查您的版本:

make --version
Run Code Online (Sandbox Code Playgroud)

它应该显示:

GNU Make 4.2.1
Built for x86_64-apple-darwin16.5.0
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later     <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Run Code Online (Sandbox Code Playgroud)

干杯.

  • 注意:`--with-default-names`已从brew中删除。请参阅[为什么删除了–with-default-names?](https://discourse.brew.sh/t/why-was-with-default-names-removed/4405/)。 (3认同)
  • 我认为你不应该将“/usr/local/Cellar/anything”放入“PATH”中,相反,你应该将“/usr/local/bin”。如果您查看那里,您将看到 Cellar 中当前版本的符号链接。这样,当您稍后升级到“make v4.3”时,您的 PATH 仍然正确,因为 **homebrew** 将重新符号链接新版本。此外,您的 PATH 对于*所有* **homebrew** 软件包来说将是正确的。 (2认同)

Dr.*_*pus 6

brew info make如果选择homebrew方式,成功后就应该使用brew install make。然后你会看到这样的文字:

\n
\n

如果您需要将其用作“make”,则可以从 bashrc 添加一个“gnubin”目录到您的 PATH,例如:
\nPATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH"

\n
\n

因此,在您的 中添加此路径.bash_profile,详细步骤为:

\n
    \n
  1. open ~/.bash_profile
  2. \n
  3. 添加行:(export PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH"您刚刚获得的路径)
  4. \n
  5. \xe2\x8c\x98 S
  6. \n
  7. source ~/.bash_profile
  8. \n
\n