Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is it necessary to use the flag -stdlib=libstdc++?

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.

like image 897
Raymond Valdes Avatar asked Nov 04 '13 18:11

Raymond Valdes


People also ask

What is the necessary of a flag?

It a positive affirmation of loyalty and commitment. It marks out a country that has confidence in itself, and is comfortable with its place in the world, its history and its future.

Why do we use our flag?

Its design and colors symbolizes countries and identify their values, beliefs and history in different ways. Each flag represents its own country and nation all around the world and conveys specific messages. For instance, the American flag stands for freedom, liberty and civil rights.

Where can I hang the Singapore flag?

The Flag should be placed on the left shoulder of the officer, while he unties the ends of the Flag from the flagpole.


1 Answers

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 (usually GNU compiler)
  • g++ -std=gnu++11 input.cxx -o a.out

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 (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

On OS X since Mavericks: libc++ is the default and you should not pass any -stdlib=<...> flag. Since Xcode 10, building against libstdc++ is not supported at all anymore. Existing code built against libstdc++ will keep working because libstdc++.6.dylib is still provided, but compiling new code against libstdc++ is not supported.

  • clang++ -std=c++11 input.cxx -o a.out
  • clang++ -std=gnu++11 input.cxx -o a.out
like image 70
Bill Lynch Avatar answered Oct 19 '22 04:10

Bill Lynch