2 回答
TA贡献1836条经验 获得超4个赞
自制程序将安装类似的东西:
/usr/local/bin/g++-10
您可以通过以下方式准确检查它安装的内容和位置:
brew ls gcc
样本输出
/usr/local/Cellar/gcc/10.2.0/bin/c++-10
/usr/local/Cellar/gcc/10.2.0/bin/cpp-10
/usr/local/Cellar/gcc/10.2.0/bin/g++-10
/usr/local/Cellar/gcc/10.2.0/bin/gcc-10
/usr/local/Cellar/gcc/10.2.0/bin/gcc-ar-10
/usr/local/Cellar/gcc/10.2.0/bin/gcc-nm-10
/usr/local/Cellar/gcc/10.2.0/bin/gcc-ranlib-10
/usr/local/Cellar/gcc/10.2.0/bin/gcov-10
/usr/local/Cellar/gcc/10.2.0/bin/gcov-dump-10
/usr/local/Cellar/gcc/10.2.0/bin/gcov-tool-10
/usr/local/Cellar/gcc/10.2.0/bin/gfortran
/usr/local/Cellar/gcc/10.2.0/bin/gfortran-10
/usr/local/Cellar/gcc/10.2.0/bin/lto-dump-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-c++-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-g++-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-10.2.0
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-ar-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-nm-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-ranlib-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gfortran-10
/usr/local/Cellar/gcc/10.2.0/include/c++/ (770 files)
/usr/local/Cellar/gcc/10.2.0/lib/gcc/ (638 files)
/usr/local/Cellar/gcc/10.2.0/libexec/gcc/ (13 files)
/usr/local/Cellar/gcc/10.2.0/share/gcc-10.2.0/ (4 files)
/usr/local/Cellar/gcc/10.2.0/share/man/ (11 files)
然后你可以找到你应该实际使用的符号链接二进制文件,如下所示:
cd /usr/local/bin
ls -l | grep gcc
样本输出
lrwxr-xr-x 1 mark admin 31 21 Aug 16:41 c++-10 -> ../Cellar/gcc/10.2.0/bin/c++-10
lrwxr-xr-x 1 mark admin 31 21 Aug 16:41 cpp-10 -> ../Cellar/gcc/10.2.0/bin/cpp-10
lrwxr-xr-x 1 mark admin 31 21 Aug 16:41 g++-10 -> ../Cellar/gcc/10.2.0/bin/g++-10
lrwxr-xr-x 1 mark admin 31 21 Aug 16:41 gcc-10 -> ../Cellar/gcc/10.2.0/bin/gcc-10
lrwxr-xr-x 1 mark admin 34 21 Aug 16:41 gcc-ar-10 -> ../Cellar/gcc/10.2.0/bin/gcc-ar-10
lrwxr-xr-x 1 mark admin 34 21 Aug 16:41 gcc-nm-10 -> ../Cellar/gcc/10.2.0/bin/gcc-nm-10
lrwxr-xr-x 1 mark admin 38 21 Aug 16:41 gcc-ranlib-10 -> ../Cellar/gcc/10.2.0/bin/gcc-ranlib-10
lrwxr-xr-x 1 mark admin 32 21 Aug 16:41 gcov-10 -> ../Cellar/gcc/10.2.0/bin/gcov-10
lrwxr-xr-x 1 mark admin 37 21 Aug 16:41 gcov-dump-10 -> ../Cellar/gcc/10.2.0/bin/gcov-dump-10
lrwxr-xr-x 1 mark admin 37 21 Aug 16:41 gcov-tool-10 -> ../Cellar/gcc/10.2.0/bin/gcov-tool-10
lrwxr-xr-x 1 mark admin 33 21 Aug 16:41 gfortran -> ../Cellar/gcc/10.2.0/bin/gfortran
lrwxr-xr-x 1 mark admin 36 21 Aug 16:41 gfortran-10 -> ../Cellar/gcc/10.2.0/bin/gfortran-10
lrwxr-xr-x 1 mark admin 36 21 Aug 16:41 lto-dump-10 -> ../Cellar/gcc/10.2.0/bin/lto-dump-10
lrwxr-xr-x 1 mark admin 53 21 Aug 16:41 x86_64-apple-darwin19-c++-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-c++-10
lrwxr-xr-x 1 mark admin 53 21 Aug 16:41 x86_64-apple-darwin19-g++-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-g++-10
lrwxr-xr-x 1 mark admin 53 21 Aug 16:41 x86_64-apple-darwin19-gcc-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-10
lrwxr-xr-x 1 mark admin 57 21 Aug 16:41 x86_64-apple-darwin19-gcc-10.2.0 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-10.2.0
lrwxr-xr-x 1 mark admin 56 21 Aug 16:41 x86_64-apple-darwin19-gcc-ar-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-ar-10
lrwxr-xr-x 1 mark admin 56 21 Aug 16:41 x86_64-apple-darwin19-gcc-nm-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-nm-10
lrwxr-xr-x 1 mark admin 60 21 Aug 16:41 x86_64-apple-darwin19-gcc-ranlib-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-ranlib-10
lrwxr-xr-x 1 mark admin 58 21 Aug 16:41 x86_64-apple-darwin19-gfortran-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gfortran-10
因此,一旦确定要使用哪个编译器,您需要告诉构建工具如何使用它。我不熟悉您提到的软件包,但您帖子的第四行暗示它正在使用,/usr/bin/g++如果您想使用 homebrew ,这是不正确的 /usr/local/bin/g++-10。
指定不同编译器的常见方法是:
对于CMake:
CXX=/usr/local/bin/g++-10 cmake ..
对于品牌:
make CXX=/usr/local/bin/g++-10
对于自动配置:
./configure CXX=/usr/local/bin/g++-10
TA贡献1846条经验 获得超7个赞
我花了很长时间,最终出现了两个我认为对其他人可能有用的主要问题。
ChemPy 仅在 Linux 上受支持,因此即使我让编译器正常工作,我也没有使其在 Mac 或 Windows 上运行。
编译器一团糟。最后有效的是使用 Anaconda 环境中的 clang v10 而不是 v12:
export CC=/usr/bin/clang export CXX=/usr/bin/clang++
为了使它完整,这里是现有的和工作的:
(base) bash-3.2$ clang --version clang version 10.0.0 Target: x86_64-apple-darwin19.6.0 Thread model: posix InstalledDir: /Users/user/anaconda3/bin (base) bash-3.2$ which clang /Users/user/anaconda3/bin/clang
- 2 回答
- 0 关注
- 227 浏览
添加回答
举报