[英]Why is g++ linked to clang, not clang++, by the mac developer tools?
I was just trying to explain to someone the difference between compiled and interpreted code, when I was greeted with a我正试图向某人解释编译代码和解释代码之间的区别,当我遇到
main.cpp:1:10: fatal error: 'iostream' file not found
when calling g++ main.cpp for a simple hello world c++ file.当为简单的 hello world c++ 文件调用 g++ main.cpp 时。
I looked into this a bit and found...我对此进行了一些调查,发现...
JM:Desktop user$ which g++
/usr/local/bin/g++
JM:Desktop user$ ls -al /usr/local/bin/g++
lrwxr-xr-x 1 user admin 47 4 Dez 2018 /usr/local/bin/g++ -> /Library/Developer/CommandLineTools/usr/bin/c++
JM:Desktop user$ ls -al /Library/Developer/CommandLineTools/usr/bin/c++
lrwxr-xr-x 1 root wheel 5 3 Feb 20:29 /Library/Developer/CommandLineTools/usr/bin/c++ -> clang
...that g++ is linked to clang and not clang++ and I therefore call the C-compiler. ...g++ 链接到 clang 而不是 clang++,因此我调用 C 编译器。
I just deleted the Developer tools and installed them again - same thing.我刚刚删除了开发人员工具并重新安装了它们 - 同样的事情。
Is this normal or did something mess up my system?这是正常现象还是我的系统出了问题? Does it make any sense?
这有意义吗? What am I missing?
我错过了什么?
Thanks for the help!谢谢您的帮助!
It may actually be Homebrew's fault somehow...这实际上可能是 Homebrew 的错......
JM:Desktop user$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin
/usr/local/bin is added by Homebrew. /usr/local/bin 由 Homebrew 添加。
'C++' for example links correctly to clang++ but it is in /usr/bin:例如,“C++”正确链接到 clang++,但它位于 /usr/bin 中:
JM:Desktop user$ which c++
/usr/bin/c++
...and so is /usr/bin/g++. ... /usr/bin/g++ 也是如此。
I solved it by just deleting /user/local/bin/g++.我通过删除 /user/local/bin/g++ 解决了这个问题。 The links are still strange.
这些链接仍然很奇怪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.