繁体   English   中英

Ubuntu编译器(C ++)

[英]Ubuntu compilers (C++)

我是Linux编程新手(Ubuntu服务器)。

说明之间有什么区别:

c++ -c  main.cpp -o main.o -lstdc++
c++ -c  Console.cpp -o Console.o -lstdc++
c++ main.o Console.o -o App1

和这个:

g++ -c  main.cpp -o main.o -lstdc++
g++ -c  Console.cpp -o Console.o -lstdc++
g++ main.o Console.o -o App1

这些说明是否相同? c ++指令是否为g ++提供了另一个名称?

update-alternatives --display c++

是的,默认是g ++。 你可以使用update-alternatives --display c++来检查它update-alternatives --display 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

他们都使用我相信的GNU C ++编译器。 所以是的,他们是一样的。

他们可能是一样的。 你可以明确检查:

哪个c ++

的/ usr / bin中/ C ++

ls -l / usr / bin / c ++

的/ etc /替代/ C ++

ls -l etc / alternatives / c ++

的/ usr /斌/克++

是的,他们是一样的,打字

which c++

给你c++实际上是/usr/bin/c++ 然后输入

ll /usr/bin/c++

会给你

lrwxrwxrwx 1 root root 21 Sep  4 17:00 /usr/bin/c++ -> /etc/alternatives/c++*

然后

ll /etc/alternatives/c++

会给你

lrwxrwxrwx 1 root root 12 Sep  4 17:00 /etc/alternatives/c++ -> /usr/bin/g++*

所以是的,它们是相同的(有一个从c ++到g ++的符号链接)。

只是找你自己:

$ 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 21 Jun 2 19:41 / usr / bin / c ++ - > / etc / alternatives / c ++ *
lrwxrwxrwx 1 root root7Mär132012 / usr / bin / g ++ - > g ++ - 4.6 *

或做:

$ c++ -v

$ g++ -v

g++表示GNU C ++编译器。

c++表示非特定的C ++编译器,但必须链接到特定的C ++编译器。 如果在您的情况下,这只是GNU C ++编译器的符号链接,那么没有区别。 但是,您可以使符号链接指向不同的C ++编译器。

是。

以下是如何弄清楚这些类型的事情

要查找可执行文件的路径:

which c++

要检查它是文件还是符号链接:

ls -ald `which c++`

要检查它是什么类型的文件:

file `which c++`

要获得可用于将其与其他文件进行比较的校验和:

md5sum `which c++`

这是检查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.

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