如何在 mac 上安装 build-essential?

How to install build-essential on mac?

build-essential 在 Debian/Ubuntu、

上安装正常
$ apt search build-essential
build-essential - Informational list of build-essential packages

$ sudo apt install build-essential

但似乎在 brew/mac 上不可用:

brew install build-essential
Error: No available formula with the name "build-essential" 
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...

如何在 Mac 上安装 build-essential

Homebrew (brew) 与 apt-get 不同,并且没有相同的包。特别是,build-essential 不是 Homebrew 包。包 build-essential is a Debian package。来自 apt show build-essential

If you do not plan to build Debian packages, you don't need this package. Starting with dpkg (>= 1.14.18) this package is required for building Debian packages.

This package contains an informational list of packages which are considered essential for building Debian packages. This package also depends on the packages on that list, to make it easy to have the build-essential packages installed.

您可以使用 Xcode 安装编译器和支持实用程序。首先,从 Mac App Store 下载 Xcode,然后在终端中 运行 安装 Xcode 的命令行工具:

$ xcode-select --install

(不过,如果您已经安装了 Homebrew,您可能已经安装了 Xcode 及其命令行工具。)