简体   繁体   中英

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.

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.

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...

JM:Desktop user$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin

/usr/local/bin is added by Homebrew.

'C++' for example links correctly to clang++ but it is in /usr/bin:

JM:Desktop user$ which c++
/usr/bin/c++

...and so is /usr/bin/g++.

I solved it by just deleting /user/local/bin/g++. The links are still strange.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM