什么时候需要使用-stdlib = libstdc ++标志? [英] When is it necessary to use the flag -stdlib=libstdc++?
问题描述
在使用gcc进行编译时,何时需要使用标志 -stdlib = libstdc ++
用于编译器和链接器?
When is it necessary to use use the flag -stdlib=libstdc++
for the compiler and linker when compiling with gcc?
编译器是否自动使用libstdc ++?
Does the compiler automatically use libstdc++?
我在Ubuntu 13.10上使用gcc4.8.2,并且我想使用c ++ 11标准。我已经将 -std = c ++ 11
传递给了编译器。
I am using gcc4.8.2 on Ubuntu 13.10 and I would like to use the c++11 standard. I already pass -std=c++11
to the compiler.
推荐答案
在Linux上:通常,默认情况下,所有常用的Linux发行版都将使用libstdc ++,而所有GCC的现代版本均随附支持C ++ 11的libstdc ++。如果要在此处编译c ++ 11代码,请使用以下之一:
On Linux: In general, all commonly available linux distributions will use libstdc++ by default, and all modern versions of GCC come with a libstdc++ that supports C++11. If you want to compile c++11 code here, use one of:
-
g ++ -std = c + +11 input.cxx -o a.out
(通常是GNU编译器) -
g ++ -std = gnu ++ 11 input.cxx -o a.out
g++ -std=c++11 input.cxx -o a.out
(usually GNU compiler)g++ -std=gnu++11 input.cxx -o a.out
在小牛之前的OS X上:<$实际上,c $ c> g ++ 是 clang ++
的别名,而Apple的旧版本的libstdc ++是默认名称。您可以通过传递 -stdlib = libc ++
来使用libc ++(其中包括c ++ 11库支持)。如果要在此处编译c ++ 11代码,请使用以下之一:
On OS X before Mavericks: g++
was actually an alias for clang++
and Apple's old version of libstdc++ was the default. You could use libc++ (which included c++11 library support) by passing -stdlib=libc++
. If you want to compile c++11 code here, use one of:
-
g ++ -std = c + +11 -stdlib = libc ++ input.cxx -o a.out
(c语,不是GNU编译器!) -
g ++ -std = gnu ++ 11 -stdlib = libc ++ input.cxx -o a.out
(c语,不是GNU编译器!) -
clang ++- std = c ++ 11 -stdlib = libc ++ input.cxx -o a.out
-
clang ++ -std = gnu ++ 11 -stdlib = libc ++ input.cxx -o a.out
g++ -std=c++11 -stdlib=libc++ input.cxx -o a.out
(clang, not GNU compiler!)g++ -std=gnu++11 -stdlib=libc++ input.cxx -o a.out
(clang, not GNU compiler!)clang++ -std=c++11 -stdlib=libc++ input.cxx -o a.out
clang++ -std=gnu++11 -stdlib=libc++ input.cxx -o a.out
自小牛以来在OS X上:libc ++是默认设置。您可以通过传递 -stdlib = libstdc ++
On OS X since Mavericks: libc++ is the default. You can use Apple's old version of libstdc++ (which does not include c++11 library support) by passing -stdlib=libstdc++
-
clang ++ -std = c ++ 11 input.cxx -o a.out
-
clang ++ -std = gnu ++ 11 input.cxx -o a.out
clang++ -std=c++11 input.cxx -o a.out
clang++ -std=gnu++11 input.cxx -o a.out
这篇关于什么时候需要使用-stdlib = libstdc ++标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!