こんにちは
Homebrew for Linux が公式サポートされ 、実際にインストールして試してみました1。最新バージョン(例えば GitHub の latest バージョン)をほぼ常に使いたい場合には解となりそうです。
$ brew --version
Homebrew 2.0.2
Linuxbrew/homebrew-core (git revision 26046; last commit 2019-02-26)
$ brew install gcc binutils
$ g++ --version
g++ (Homebrew gcc 5.5.0_4) 5.5.0
$ ld --version
GNU ld (GNU Binutils) 2.32
$ which gcc
/home/linuxbrew/.linuxbrew/bin/gcc
$ which ld
/home/linuxbrew/.linuxbrew/bin/ld
標準的なコンパイル方法例は、
$ g++ -std=c++11 -I/usr/include -I$HOMEBREW_PREFIX/include -L$HOMEBREW_PREFIX/lib test.cpp
なお MacOSX (の Homebrew)の場合では、Xcode でインストールした clang++
を使い、/bin/ls
を使うところが、比較すると異なっている気がしました。
-
「brewがlinuxで使えるらしいのでやってみる」などで紹介されています。 ↩