【发布时间】:2020-08-02 14:44:01
【问题描述】:
我最近在我的 MacOS 10.14.6 上安装了 g++-10 和 Homebew。我在.zshrc 文件中创建了一个别名:
alias g++="/usr/local/bin/g++-10"
为了在终端中自动编译和运行,我创建了一个.sh 文件。但是,我注意到从终端手动调用 g++ 时使用的 g++ 版本如下:
$ g++ --version
g++-10 (Homebrew GCC 10.2.0) 10.2.0
Copyright (C) 2020 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.
这与从.sh 脚本调用 g++ 的不同。脚本displayg++Version.sh的内容是:
type g++
g++ --version
然后脚本调用的输出是:
g++ is /usr/bin/g++
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
这是以下命令的输出:
$ type g++
g++ is an alias for /usr/local/bin/g++-10
为什么两个版本不同?
【问题讨论】:
-
为什么问题有
bash标签? -
@Cyrus 因为我使用了 bash 并且我的机器中仍然有一个 bash 配置文件,所以我不知道它是否相关。我在那里写了相同的别名。如果你愿意,我可以删除标签
-
将
type g++的输出添加到您的问题(无评论)。 -
@Cyrus。我只是按照你的要求写的
-
zsh在你的脚本中使用你的alias吗?
标签: bash shell terminal g++ zsh