什么时候需要使用使用标志-stdlib = libstdc ++? [英] When is it necessary to use use the flag -stdlib=libstdc++?

查看:1148
本文介绍了什么时候需要使用使用标志-stdlib = libstdc ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用gcc编译时,何时需要使用标志 -stdlib = libstdc ++ 用于编译器和链接器?



编译器是否自动使用libstdc ++?



我在Ubuntu 13.10上使用gcc4.8.2,我想使用c ++ 11标准。我已经通过 -std = c ++ 11 到编译器。

解决方案

在Linux :一般来说,所有常见的linux发行版都会默认使用libstdc ++。如果你想在这里编译c ++ 11代码,请使用以下命令之一:




  • g ++ -std = c + +11 input.cxx -o a.out

  • g ++ -std = gnu ++ 11 input.cxx -o a.out


在小牛之前的OS X上:libstdc ++是默认值。您可以通过传递 -stdlib = libc ++ 使用libc ++(包括c ++ 11库支持)。如果你想在这里编译c ++ 11代码,请使用以下命令之一:




  • g ++ -std = c + +11 -stdlib = libc ++ input.cxx -o a.out

  • g ++ -std = gnu ++ 11 -stdlib = libc ++ input.cxx -o a.out

  • clang ++ -std = c ++ 11 -stdlib = libc ++ input.cxx -o a .out

  • clang ++ -std = gnu ++ 11 -stdlib = libc ++ input.cxx -o a.out



在Mavericks OS X上:libc ++是默认值。您可以通过传递 -stdlib = libstdc ++



来使用libstdc ++(不包括c ++ 11库支持)
  • clang ++ -std = c ++ 11 input.cxx -o a.out

  • clang ++ -std = gnu ++ 11 input.cxx -o a.out


  • When is it necessary to use use the flag -stdlib=libstdc++ for the compiler and linker when compiling with gcc?

    Does the compiler automatically use libstdc++?

    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.

    解决方案

    On Linux: In general, all commonly available linux distributions will use libstdc++ by default. If you want to compile c++11 code here, use one of:

    • g++ -std=c++11 input.cxx -o a.out
    • g++ -std=gnu++11 input.cxx -o a.out

    On OS X before Mavericks: 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
    • g++ -std=gnu++11 -stdlib=libc++ input.cxx -o a.out
    • clang++ -std=c++11 -stdlib=libc++ input.cxx -o a.out
    • clang++ -std=gnu++11 -stdlib=libc++ input.cxx -o a.out

    On OS X since Mavericks: libc++ is the default. You can use 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

    这篇关于什么时候需要使用使用标志-stdlib = libstdc ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆