[英]Ubuntu compilers (C++)
I am new for Linux programming (Ubuntu server). 我是Linux编程新手(Ubuntu服务器)。
What difference between instructions: 说明之间有什么区别:
c++ -c main.cpp -o main.o -lstdc++
c++ -c Console.cpp -o Console.o -lstdc++
c++ main.o Console.o -o App1
and this: 和这个:
g++ -c main.cpp -o main.o -lstdc++
g++ -c Console.cpp -o Console.o -lstdc++
g++ main.o Console.o -o App1
Are these instructions the same? 这些说明是否相同? Is c++ instruction provides another name for g++? c ++指令是否为g ++提供了另一个名称?
update-alternatives --display c++
Yes, default is g++. 是的,默认是g ++。 You can check it using update-alternatives --display c++
; 你可以使用update-alternatives --display c++
来检查它update-alternatives --display c++
; change it via sudo update-alternatives c++
通过sudo update-alternatives c++
改变它
update-alternatives --config c++
There are 2 choices for the alternative c++ (providing /usr/bin/c++).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/g++ 20 auto mode
1 /usr/bin/clang++ 10 manual mode
2 /usr/bin/g++ 20 manual mode
They both use the GNU C++ compiler I believe. 他们都使用我相信的GNU C ++编译器。 So yes, they are the same. 所以是的,他们是一样的。
They are probably the same. 他们可能是一样的。 You can check explicitly: 你可以明确检查:
which c++ 哪个c ++
/usr/bin/c++ 的/ usr / bin中/ C ++
ls -l /usr/bin/c++ ls -l / usr / bin / c ++
/etc/alternatives/c++ 的/ etc /替代/ C ++
ls -l etc/alternatives/c++ ls -l etc / alternatives / c ++
/usr/bin/g++ 的/ usr /斌/克++
Yes they are the same, typing 是的,他们是一样的,打字
which c++
gives you that c++
is in fact /usr/bin/c++
. 给你c++
实际上是/usr/bin/c++
。 then typing 然后输入
ll /usr/bin/c++
will give you 会给你
lrwxrwxrwx 1 root root 21 Sep 4 17:00 /usr/bin/c++ -> /etc/alternatives/c++*
then 然后
ll /etc/alternatives/c++
will give you 会给你
lrwxrwxrwx 1 root root 12 Sep 4 17:00 /etc/alternatives/c++ -> /usr/bin/g++*
so yes, they are the same (there is a symbolic link from c++ to g++). 所以是的,它们是相同的(有一个从c ++到g ++的符号链接)。
Just look for yourself: 只是找你自己:
$ ls -l /usr/bin/c++ /usr/bin/g++ /etc/alternatives/c++
lrwxrwxrwx 1 root root 12 Jun 2 19:41 /etc/alternatives/c++ -> /usr/bin/g++* lrwxrwxrwx 1 root root 12 Jun 2 19:41 / etc / alternatives / c ++ - > / usr / bin / g ++ *
lrwxrwxrwx 1 root root 21 Jun 2 19:41 /usr/bin/c++ -> /etc/alternatives/c++* lrwxrwxrwx 1 root root 21 Jun 2 19:41 / usr / bin / c ++ - > / etc / alternatives / c ++ *
lrwxrwxrwx 1 root root 7 Mär 13 2012 /usr/bin/g++ -> g++-4.6* lrwxrwxrwx 1 root root7Mär132012 / usr / bin / g ++ - > g ++ - 4.6 *
or do: 或做:
$ c++ -v
vs. 与
$ g++ -v
g++
means the GNU C++ compiler. g++
表示GNU C ++编译器。
c++
means a non-specific C++ compiler but it has to be linked to a specific one. c++
表示非特定的C ++编译器,但必须链接到特定的C ++编译器。 If in your case, this is just a symbolic link to the GNU C++ compiler then there is no difference. 如果在您的情况下,这只是GNU C ++编译器的符号链接,那么没有区别。 However you could make the symbolic link point to a different C++ compiler. 但是,您可以使符号链接指向不同的C ++编译器。
Yes. 是。
Here's how to figure out these types of things 以下是如何弄清楚这些类型的事情
To find the path to an executable: 要查找可执行文件的路径:
which c++
To check if it's a file or a symbolic link: 要检查它是文件还是符号链接:
ls -ald `which c++`
To check what type of file it is: 要检查它是什么类型的文件:
file `which c++`
To get a checksum that can be used to compare it to other files: 要获得可用于将其与其他文件进行比较的校验和:
md5sum `which c++`
Here's one way of checking if c++ and g++ are equal: 这是检查c ++和g ++是否相等的一种方法:
[ `md5sum $(which c++) | cut -d' ' -f1` == `md5sum $(which g++) | cut -d' ' -f1` ] && echo Yes, equal content || echo No, unequal content
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.