Should I use libc++ or libstdc++? [closed]

喜你入骨 提交于 2019-11-27 17:22:21
Jonathan Wakely

I would use the native library for each OS i.e. libstdc++ on GNU/Linux and libc++ on Mac OS X.

libc++ is not 100% complete on GNU/Linux, and there's no real advantage to using it when libstdc++ is more complete. Also, if you want to link to any other libraries written in C++ they will almost certainly have been built with libstdc++ so you'll need to link with that too to use them.

More info here about the completeness of libc++ on various platforms.

Major Linux distributions do not provide LLVM libc++, because:

  1. Unlike Apple and FreeBSD, the GPL+3 is not an issue, so no need to implement another stack here.
  2. Linux components have been developed around GNU libstd++ for ages. Some of them do not build on anything else.
  3. While libc++ is strong in new features, it has some problems with legacy code.

If eventually libc++ became part of distributions, it will be as an optional component. linking against it will probably require extra options.

Like Jonathan said, you should use whatever tool is included by default. Clang is safe in Linux to use since is configured as a GCC replacement, so in that aspect you don't have to worry about 2 compilers. Also since you are targeting two platforms, you should take a look to cmake.

it is said libc++ has more human readable error messages on template errors.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!