“g++"和“c++"编译器

2022-01-23 00:00:00 ubuntu g++ compiler-construction c++

我刚刚在我的 Ubuntu 上发现,有两种不同的 C++ 编译器:/usr/bin/g++/usr/bin/c++.我对后者不熟悉,但 man c++ 只是跳转到 gcc 的手册页.我想知道它们作为 C++ 编译器有什么区别?

I just found on my Ubuntu, there are two different C++ compilers: /usr/bin/g++ and /usr/bin/c++. I am not familiar with the latter, but man c++ just jumps to the manpage of gcc. I wonder what is their difference as C++ compilers?

推荐答案

这是典型的 Ubuntu 符号链接混乱.

This is typical Ubuntu symlink mayhem.

如果你ls -l/usr/bin/c++,你会发现它实际上是一个符号链接.到:

If you ls -l /usr/bin/c++, you will see it is actually a symbolic link. to:

/etc/alternatives/c++

这又是一个符号链接:

/usr/bin/g++

所以,在 Ubuntu 系统上,c++ 是 g++.链接间接背后的原因是有多个包可以提供 c++ 编译器(例如不同版本的 g++).你会在 Ubuntu 上看到很多.例如,qmake 是指向/etc/alternatives 中文件的链接,它(在我的系统上)是指向/usr/bin/qmake-qt3 的链接.

So, on Ubuntu systems, c++ is g++. The reasoning behind the link indirection is that there are multiple packages that could provide a c++ compiler (such as different versions of g++). You'll see this a lot on Ubuntu. For example, qmake is a link to a file in /etc/alternatives, which is (on my system) a link back to /usr/bin/qmake-qt3.

相关文章