Given that now the GCC package in brew finally supports Arm Macs and comes with libstdc++ With this, clang return the following warnings and errors If you've installed libstdc++ as part of GCC, you should probably use GCC instead of clang. Answer from celestrion on reddit.com
🌐
Reddit
reddit.com › r/cpp_questions › using libstdc++ with clang on arm macs
r/cpp_questions on Reddit: Using libstdc++ with clang on arm Macs
April 17, 2024 -

TLDR: How to build a ninja project with clang 18 and libstdc++13 on an arm Mac?

Hi!

I was investigating a bit regarding the usage of libstdc++ with clang on arm Macs in order to use the same "configuration" of my coworkers on linux.

Giving a bit of context. I'm using C++20 (23 in a few weeks!) staying as far away as possible from Xcode and its build system: I'm using clang 18 with its own libc++ and the ninja build system.

Given that now the GCC package in brew finally supports Arm Macs and comes with libstdc++, I've tried to compile the project I'm working on, adding those two lines in our CompilerOptions.cmake file:

add_compile_options(-stdlib=libstdc++ -I/opt/homebrew/opt/gcc/include/c++/13)

add_link_options(-Wl,-rpath,/opt/homebrew/opt/gcc/lib/gcc/13)

With this, clang return the following warnings and errors:

clang++: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]

/opt/homebrew/opt/gcc/include/c++/13/bits/requires_hosted.h:31:10: fatal error: 'bits/c++config.h' file not found

31 | #include <bits/c++config.h>

The errors derives from the fact that clang does not recognise the `aarch64-apple-darwin23` directory in the headers. Linking the folder in the compile option "solve" the error:

add_compile_options(-stdlib=libstdc++ -I/opt/homebrew/opt/gcc/include/c++/13 -I/opt/homebrew/opt/gcc/include/c++/13/aarch64-apple-darwin23)

add_link_options(-Wl,-rpath,/opt/homebrew/opt/gcc/lib/gcc/13)

With this clang fails with tons of these warnings/errors:

clang++: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
....
infinite message like this:
....
"vtable for llvm::cl::opt<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, false, llvm::cl::parser<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>", referenced from:
  llvm::cl::opt<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, false, llvm::cl::parser<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>::opt<char [17], llvm::cl::desc, llvm::cl::initializer<char [1]>, llvm::cl::value_desc, llvm::cl::cat>(char const (&) [17], llvm::cl::desc const&, llvm::cl::initializer<char [1]> const&, llvm::cl::value_desc const&, llvm::cl::cat const&) in libCommandLine.a[2](CommandLine.cpp.o)

NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.

What am I doing wrong? Using libstdc++ is possible in principle on an arm-based Mac?

Thank you all in advance!

🌐
GitHub
github.com › compiler-explorer › compiler-explorer › issues › 3682
[BUG]: Compiler Explorer uses libstdc++ with Clang by default · Issue #3682 · compiler-explorer/compiler-explorer
May 17, 2022 - On Linux, the Clang compiler defaults to using libstdc++. The reason is that libstdc++ is the standard library shipped with the system on most Linux distributions, so Clang needs to use it in order to produce software that is compatible with ...
Author   compiler-explorer
Discussions

c++ - Static link libstdc++ using clang - Stack Overflow
When I use GCC, I can build program on my Ubuntu 15.04 using this: -static-libgcc -static-libstdc++ And compiled binary can run on "stock" Ubuntu 14.04 without any external packages, only standard More on stackoverflow.com
🌐 stackoverflow.com
c++ - How to detect the libstdc++ version in Clang? - Stack Overflow
I would like to write a "portable" C++ library in Clang. "Portable" means that I detect (in C preprocessor) what C++ features are available in the compilation environment and use these features or More on stackoverflow.com
🌐 stackoverflow.com
Which version of libc++/libstdc++ clang take to compile ?
On linux you'll pretty much always use libstdc++. Based on the includes, you're using libstdc++ version 12, i.e. the library corresponding to g++12. More on reddit.com
🌐 r/cpp_questions
2
1
June 23, 2023
[question] Is libstdc++11 used in Linux clang?
Coming from conan-io/conan-center-index#1091 I have looked for more information regarding libstdc++11 and clang in Linux and I did not found anything in the documentation, only this that I suppose ... More on github.com
🌐 github.com
9
May 12, 2020
Top answer
1 of 3
120

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
2 of 3
39

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

Short answer: never

Longer answer: -stdlib is a Clang flag and will not work with any version of GCC ever released. On macOS sometimes the gcc and g++ commands are actually aliases for Clang not GCC, and the version of libstdc++ that Apple ships is ancient (circa 2008) so of course it doesn't support C++11. This means that on macOS when using Clang-pretending-to-be-GCC, you can use -stdlib=libc++ to select Clang's new C++11-compatible library, or you can use -stdlib=libstdc++ to select the pre-C++11 antique version of libstdc++ that belongs in a museum. But on GNU/Linux gcc and g++ really are GCC not Clang, and so the -stdlib option won't work at all.

Edit: Since I wrote this answer, GCC was changed to conditionally support the -stdlib flag, but for most platforms that support is disabled by default. Even when it's enabled, the default is -stdlib=libstdc++ so you still never need to say that explicitly. GCC will still automatically use libstdc++.

Does the compiler automatically use libstdc++?

Yes, GCC always uses libstdc++ unless you tell it to use no standard library at all with the -nostdlib or -nostdlib++ option (in which case you either need to avoid using any standard library features, or use -I and -L and -l flags to point it to an alternative set of header and library files).

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.

You don't need to do anything else. GCC comes with its own implementation of the C++ standard library (libstdc++) which is developed and tested alongside GCC itself so the version of GCC and the version of libstdc++ are 100% compatible. If you compile with -std=c++11 then that enables the C++11 features in g++ compiler and also the C++11 features in the libstdc++ headers.

🌐
LLVM
releases.llvm.org › 5.0.0 › tools › clang › docs › Toolchain.html
Assembling a Complete Toolchain — Clang 5 documentation
You can instruct Clang to use libc++ with the -stdlib=libc++ flag. libstdc++ is GCC’s implementation of the C++ standard library.
Top answer
1 of 2
19

clang is compatible with gcc on this matter. Basically for hello-world program that uses iostream to ensure libstdc++ requirement (actual lib versions may vary between distributions):

$ clang++ test.cpp
$ ldd ./a.out
        linux-vdso.so.1 (0x00007ffec65c0000)
        libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/libstdc++.so.6 (0x00007ff937bb6000)
        libm.so.6 => /lib64/libm.so.6 (0x00007ff9378b6000)
        libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/libgcc_s.so.1 (0x00007ff93769e000)
        libc.so.6 => /lib64/libc.so.6 (0x00007ff9372fe000)
        /lib64/ld-linux-x86-64.so.2 (0x00007ff937f3e000)

Here is a dependency for libstdc++ and libgcc_s. But if you add -static-libgcc -static-libstdc++:

$ clang++ test.cpp -static-libgcc -static-libstdc++
$ ldd ./a.out
        linux-vdso.so.1 (0x00007ffe5d678000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fb8e4516000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fb8e4176000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fb8e4816000)

That still leaves dependency on libc, but that is a different question.

clang: warning: argument unused during compilation: '-static-libstdc++' means clang ignored this flag, because flag is useless in current situation. First two examples that coming to mind is compiling C code (which obviously don't depend on libstdc++), or issuing compile-only command without linking (-c flag). Since .o file cannot hold information about static or dynamic linking, this flag have to be specified on linking phase (and, to avoid warning, only on linking phase).

2 of 2
1

Instead of using -static-libstdc++ or -static-libgcc, just use clang's -static flag. It will produce a non dynamic executable, with everything it needs linked in statically.

On my test program, it produces:

[root@interserver ogrerobot.com]# ldd ./CppUtilsSpikes  
not a dynamic executable
🌐
LLVM
releases.llvm.org › 6.0.0 › projects › libcxx › docs › UsingLibcxx.html
Using libc++ — libc++ 6.0 documentation
$ clang++ -stdlib=libc++ test.cpp -lc++ -lc++abi -lm -lc -lgcc_s -lgcc · Alternately, you could just add libc++abi to your libraries list, which in most situations will give the same result: ... GCC does not provide a way to switch from libstdc++ to libc++. You must manually configure the compile and link commands.
🌐
Reddit
reddit.com › r/cpp_questions › which version of libc++/libstdc++ clang take to compile ?
r/cpp_questions on Reddit: Which version of libc++/libstdc++ clang take to compile ?
June 23, 2023 -

I have some errors that I cannot reproduce except on my system. When I use some views from c++20, il have weird error about constraint not met about begin, sentinel and range_iter_t. I manually (not from the package manager) installed clang++16 on linux (ubuntu 22.04). On godbolt, everything works (https://godbolt.org/z/Wbbz5aEqM) .

When I type clang++ --version, it says 14.0.0. When I type clang++-16 --version, it says 16.0.5.

I also have g++12 but when I type g++ --version, it says 11.3.0.

Here is the cmake command I run:

export CC=/usr/bin/clang-16
export CXX=/usr/bin/clang++-16
export CUDACXX=/usr/local/cuda/bin/nvcc
export CLAZY_IGNORE_DIRS="/usr/*"
cmake -B build -S . -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_CXX_COMPILER=clazy -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build -j`nproc`

Is it possible that clang++-16 use an stl implmentation from clang14 or gcc11 ?

Here is the errors I get:

In file included from /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:1:
In file included from /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.h:3:
In file included from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QComboBox:1:
In file included from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qcombobox.h:43:
In file included from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qtwidgetsglobal.h:43:
In file included from /usr/include/x86_64-linux-gnu/qt5/QtGui/qtguiglobal.h:43:
In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:142:
In file included from /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/algorithm:60:
In file included from /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_algobase.h:65:
In file included from /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_iterator_base_types.h:71:
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:982:13: error: no matching function for call to '__begin'
        = decltype(ranges::__cust_access::__begin(std::declval<_Tp&>()));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/ranges_base.h:595:5: note: in instantiation of template type alias '__range_iter_t' requested here
    using iterator_t = std::__detail::__range_iter_t<_Tp>;
    ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/ranges_util.h:121:36: note: in instantiation of template type alias 'iterator_t' requested here
      requires contiguous_iterator<iterator_t<_Derived>>
                                   ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1098:29: note: in instantiation of template class 'std::ranges::view_interface<std::ranges::ref_view<const std::vector<BaseObject *>>>' requested here
    class ref_view : public view_interface<ref_view<_Range>>
                            ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1233:38: note: in instantiation of template class 'std::ranges::ref_view<const std::vector<BaseObject *>>' requested here
        concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; };
                                            ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1233:38: note: in instantiation of requirement here
        concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; };
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1233:27: note: (skipping 20 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
        concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; };
                                 ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:832:9: note: while substituting template arguments into constraint expression here
      = requires { std::declval<_Adaptor>()(declval<_Args>()...); };
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:857:5: note: while checking the satisfaction of concept '__adaptor_invocable<std::ranges::views::__adaptor::_Partial<std::ranges::views::_Transform, (lambda at /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:37)>, const std::vector<BaseObject *> &>' requested here
        && __adaptor_invocable<_Self, _Range>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:857:5: note: while substituting template arguments into constraint expression here
        && __adaptor_invocable<_Self, _Range>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:13: note: while checking constraint satisfaction for template 'operator|<std::ranges::views::__adaptor::_Partial<std::ranges::views::_Transform, (lambda at /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:37)>, const std::vector<BaseObject *> &>' required here
            | std::views::transform([](auto *object) { return object->objectName(); })
            ^
/home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:13: note: in instantiation of function template specialization 'std::ranges::views::__adaptor::operator|<std::ranges::views::__adaptor::_Partial<std::ranges::views::_Transform, (lambda at /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:37)>, const std::vector<BaseObject *> &>' requested here
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:966:7: note: candidate template ignored: constraints not satisfied [with _Tp = std::ranges::ref_view<const std::vector<BaseObject *>>]
      __begin(_Tp& __t)
      ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:964:16: note: because 'is_array_v<std::ranges::ref_view<const std::vector<BaseObject *> > >' evaluated to false
      requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
               ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:964:35: note: and 'std::ranges::ref_view<const std::vector<BaseObject *>> &' does not satisfy '__member_begin'
      requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
                                  ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:947:23: note: because '__decay_copy(__t.begin())' would be invalid: no member named 'begin' in 'std::ranges::ref_view<const std::vector<BaseObject *>>'
          { __decay_copy(__t.begin()) } -> input_or_output_iterator;
                             ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:964:59: note: and 'std::ranges::ref_view<const std::vector<BaseObject *>> &' does not satisfy '__adl_begin'
      requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
                                                          ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:958:19: note: because '__decay_copy(begin(__t))' would be invalid: call to deleted function 'begin'
          { __decay_copy(begin(__t)) } -> input_or_output_iterator;
                         ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:982:13: error: no matching function for call to '__begin'
        = decltype(ranges::__cust_access::__begin(std::declval<_Tp&>()));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/ranges_base.h:595:5: note: in instantiation of template type alias '__range_iter_t' requested here
    using iterator_t = std::__detail::__range_iter_t<_Tp>;
    ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/ranges_util.h:127:25: note: in instantiation of template type alias 'iterator_t' requested here
        && contiguous_iterator<iterator_t<const _Derived>>
                               ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1098:29: note: in instantiation of template class 'std::ranges::view_interface<std::ranges::ref_view<const std::vector<BaseObject *>>>' requested here
    class ref_view : public view_interface<ref_view<_Range>>
                            ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1233:38: note: in instantiation of template class 'std::ranges::ref_view<const std::vector<BaseObject *>>' requested here
        concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; };
                                            ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1233:38: note: in instantiation of requirement here
        concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; };
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1233:27: note: (skipping 20 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
        concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; };
                                 ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:832:9: note: while substituting template arguments into constraint expression here
      = requires { std::declval<_Adaptor>()(declval<_Args>()...); };
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:857:5: note: while checking the satisfaction of concept '__adaptor_invocable<std::ranges::views::__adaptor::_Partial<std::ranges::views::_Transform, (lambda at /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:37)>, const std::vector<BaseObject *> &>' requested here
        && __adaptor_invocable<_Self, _Range>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:857:5: note: while substituting template arguments into constraint expression here
        && __adaptor_invocable<_Self, _Range>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:13: note: while checking constraint satisfaction for template 'operator|<std::ranges::views::__adaptor::_Partial<std::ranges::views::_Transform, (lambda at /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:37)>, const std::vector<BaseObject *> &>' required here
            | std::views::transform([](auto *object) { return object->objectName(); })
            ^
/home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:13: note: in instantiation of function template specialization 'std::ranges::views::__adaptor::operator|<std::ranges::views::__adaptor::_Partial<std::ranges::views::_Transform, (lambda at /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:37)>, const std::vector<BaseObject *> &>' requested here
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:966:7: note: candidate template ignored: constraints not satisfied [with _Tp = const std::ranges::ref_view<const std::vector<BaseObject *>>]
      __begin(_Tp& __t)
      ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:964:16: note: because 'is_array_v<const std::ranges::ref_view<const std::vector<BaseObject *> > >' evaluated to false
      requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
               ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:964:35: note: and 'const std::ranges::ref_view<const std::vector<BaseObject *>> &' does not satisfy '__member_begin'
      requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
                                  ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:947:23: note: because '__decay_copy(__t.begin())' would be invalid: no member named 'begin' in 'std::ranges::ref_view<const std::vector<BaseObject *>>'
          { __decay_copy(__t.begin()) } -> input_or_output_iterator;
                             ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:964:59: note: and 'const std::ranges::ref_view<const std::vector<BaseObject *>> &' does not satisfy '__adl_begin'
      requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
                                                          ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/iterator_concepts.h:958:19: note: because '__decay_copy(begin(__t))' would be invalid: call to deleted function 'begin'
          { __decay_copy(begin(__t)) } -> input_or_output_iterator;
                         ^
In file included from /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:1:
In file included from /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.h:3:
In file included from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QComboBox:1:
In file included from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qcombobox.h:43:
In file included from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qtwidgetsglobal.h:43:
In file included from /usr/include/x86_64-linux-gnu/qt5/QtGui/qtguiglobal.h:43:
In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:142:
In file included from /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/algorithm:63:
In file included from /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/ranges_algo.h:36:
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/ranges_util.h:133:24: error: constraints not satisfied for alias template 'sentinel_t' [with _Range = std::ranges::ref_view<const std::vector<BaseObject *>>]
        && sized_sentinel_for<sentinel_t<_Derived>, iterator_t<_Derived>>
                              ^~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1098:29: note: in instantiation of template class 'std::ranges::view_interface<std::ranges::ref_view<const std::vector<BaseObject *>>>' requested here
    class ref_view : public view_interface<ref_view<_Range>>
                            ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1233:38: note: in instantiation of template class 'std::ranges::ref_view<const std::vector<BaseObject *>>' requested here
        concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; };
                                            ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1233:38: note: in instantiation of requirement here
        concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; };
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1233:27: note: while substituting template arguments into constraint expression here
        concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; };
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1255:7: note: while checking the satisfaction of concept '__can_ref_view<const std::vector<BaseObject *> &>' requested here
          || __detail::__can_ref_view<_Range>
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:1255:17: note: (skipping 18 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
          || __detail::__can_ref_view<_Range>
                       ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:832:9: note: while substituting template arguments into constraint expression here
      = requires { std::declval<_Adaptor>()(declval<_Args>()...); };
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:857:5: note: while checking the satisfaction of concept '__adaptor_invocable<std::ranges::views::__adaptor::_Partial<std::ranges::views::_Transform, (lambda at /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:37)>, const std::vector<BaseObject *> &>' requested here
        && __adaptor_invocable<_Self, _Range>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:857:5: note: while substituting template arguments into constraint expression here
        && __adaptor_invocable<_Self, _Range>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:13: note: while checking constraint satisfaction for template 'operator|<std::ranges::views::__adaptor::_Partial<std::ranges::views::_Transform, (lambda at /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:37)>, const std::vector<BaseObject *> &>' required here
            | std::views::transform([](auto *object) { return object->objectName(); })
            ^
/home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:13: note: in instantiation of function template specialization 'std::ranges::views::__adaptor::operator|<std::ranges::views::__adaptor::_Partial<std::ranges::views::_Transform, (lambda at /home/gitlab-runner/builds/LontYnRx/0/root/xact/shared/widgets/objectcombobox.cpp:160:37)>, const std::vector<BaseObject *> &>' requested here
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/ranges_base.h:597:12: note: because 'std::ranges::ref_view<const std::vector<BaseObject *>>' does not satisfy 'range'
  template<range _Range>
           ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/ranges_base.h:585:2: note: because 'ranges::begin(__t)' would be invalid: no matching function for call to object of type 'const __cust_access::_Begin'
        ranges::begin(__t);
        ^
Find elsewhere
🌐
GitHub
github.com › conan-io › conan › issues › 7002
[question] Is libstdc++11 used in Linux clang? · Issue #7002 · conan-io/conan
May 12, 2020 - Clang's C++11 mode can be used with libc++ or with gcc's libstdc++
Author   conan-io
🌐
Reddit
reddit.com › r/cpp_questions › some questions about libc, libc++, libstdc++
r/cpp_questions on Reddit: Some questions about libc, libc++, libstdc++
September 18, 2020 -

Can someone elaborate on what are libc, libc++, libstdc++

  1. What the difference between libc++ and libstdc++? Why can't we just use one of them for all times?

  2. How to determine which versions of these libs support specific standard version? For example which version of c++ standard does libstdc++-4.6 support?

  3. Can i just "copy-paste" these libs into target OS to run my project if that OS lacks newer versions of these ones available in repositories?

    1. Can i just "copy-paste" all dependent `.so` files into target OS? What should i consider when "copy-pasting" libraries from my development workstation to user's one?

Top answer
1 of 2
4
What the difference between libc++ and libstdc++? libc++ is part of clang project and libstdc++ is part of GCC project. They are compatible for C++17 and older versions, but C++20 implementation is not ready, so they have differences in implemented features, we'll have to wait until they are done. How to determine which versions of these libs support specific standard version? For example which version of c++ standard does libstdc++-4.6 support? In their documentation, for example you can check what version GCC libstdc++ supports here: https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html Copy pasting libs may or may not work, depending on many things. It's best to just install standard library using package manager of your operating system.
2 of 2
1
(mine) 0. What are libc++ and libstdc++ They are compiler-specific implementations of the C++ standard library. libc++ is bundled with Clang and libstdc++ with GCC. On many unix platforms Clang works with libstdc++ by default for better ABI compatibility. 1. What the difference between libc++ and libstdc++? Why can't we just use one of them for all times? They are different implementations of the same library. Your code should not really care which one it is using, unless you also want to use compiler-specific extensions. 2. How to determine which versions of these libs support specific standard version? Not sure. Look into GCC and Clang documentation. 3. Can i just "copy-paste" these libs into target OS to run my project if that OS lacks newer versions of these ones available in repositories? Can i just "copy-paste" all dependent .so files into target OS? What should i consider when "copy-pasting" libraries from my development workstation to user's one? Generally, yes but you need to take care of few things: Your executable must be able to locate the library object. This might require to edit LD_LIBRARY_PATH or inject rpath information into the executable. Licensing concerns (???) - IIRC even majority of commercial uses are fine though It's possible to use static version of the standard library - then it's inside the executable. Whatever linking you are using, the target OS must support all dependencies of the standard library implementation. This will usually be dependent on supported syscalls which are the border between user-space and kerner-space.
🌐
Apple Developer
developer.apple.com › forums › thread › 113746
clang: warning: libstdc++ … | Apple Developer Forums
February 12, 2019 - Building with libstdc++ was deprecated with Xcode 8 and is not supported in Xcode 10 when targeting iOS. C++ projects must now migrate to libc++ and are recommended to set a deployment target of macOS 10.9 or later, or iOS 7 or later.
🌐
Clang
clang.llvm.org › get_started.html
Getting Started: Building and Running Clang - LLVM.org
Note: For subsequent Clang development, you can just run make clang. CMake allows you to generate project files for several IDEs: Xcode, Eclipse CDT4, CodeBlocks, Qt-Creator (use the CodeBlocks generator), KDevelop3. For more details see Building LLVM with CMake page. On Linux, you may need GCC runtime libraries (e.g. crtbeginS.o, libstdc++.so) and libstdc++ headers.
🌐
GitHub
github.com › llvm › llvm-project › issues › 97842
clang++, libstdc++14, std=c++23 : lots of library code in mainstream libraries fails to build · Issue #97842 · llvm/llvm-project
July 5, 2024 - c++23clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"duplicateResolved as duplicateResolved as duplicatelibstdc++GNU libstdc++ C++ standard libraryGNU libstdc++ C++ standard library ... Some repros ; easily reproducible on an archlinux container. Ex. 1: boostorg/container#282 ... $ docker run -v $PWD:/src -it archlinux:latest $ pacman -Sy $ pacman -S clang $ echo '#include <boost/container/flat_map.hpp> int main() { boost::container::flat_map<int, int> f; f[0]; }' > foo.cpp $ clang++ foo.cpp -std=c++23 -I /src/boost_1_85_0
Author   llvm
🌐
LLVM Discussion Forums
discourse.llvm.org › clang frontend
[RFC] Take libstdc++ into account during GCC detection - Clang Frontend - LLVM Discussion Forums
June 20, 2025 - Problem statement The default C++ standard library used by Clang on GNU/Linux systems is GCC’s libstdc++. To find this library, among other things, Clang needs the path to a GCC installation directory which is autodetected (see class Generic_GCC::GCCInstallationDetector) unless the user provides it explicitly on the command line.
🌐
GNU
gcc.gnu.org › pipermail › libstdc++ › 2021-April › 052326.html
Is that possible to use clang to build libstdc++ without using GCC?
We make no attempt at portability in the libstdc++-v3/src/*/*.cc files, so they just make use of GCC extensions without checking if they are supported (because we know they are supported by GCC, and those files are only compiled by GCC). Previous message (by thread): Is that possible to use clang to build libstdc++ without using GCC?
🌐
Maven
maven.de › 2020 › 05 › using-clang-on-macos-to-compile-g-libstdc-compatible-binaries
Using clang on macOS to compile g++ / libstdc++ compatible binaries | thoughts…
May 19, 2020 - CXX=/usr/local/opt/llvm/bin/clang++ CXXFLAGS="-stdlib=libstdc++ -stdlib++-isystem /usr/local/Cellar/gcc/9.3.0_1/include/c++/9.3.0/ -cxx-isystem /usr/local/Cellar/gcc/9.3.0_1/include/c++/9.3.0/x86_64-apple-darwin19" LDFLAGS="-stdlib=libstdc++ -L /usr/local/Cellar/gcc/9.3.0_1/lib/gcc/9 -L /usr/local/opt/llvm/lib"
🌐
Discoverer
docs.discoverer.bg › clang_pp_libstcpp_abi_compat.html
Using LLVM.org Clang compilers with libstdc++ and ABI compatibility — Discoverer HPC Docs documentation
This document explains how to use clang/clang++ compilers with libstdc++ (GCC’s C++ standard library), when this is possible, and the relationship between static linking of C++ standard library implementations and ABI (Application Binary Interface) compatibility requirements when libraries expose standard library types in their public APIs.