llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.86k stars 11.91k forks source link

can not find c++20 concepts head file #56276

Closed FuXiii closed 2 years ago

FuXiii commented 2 years ago

deepin(linux) system+vscode + clang + clangd + cmake

FuXii@FuXii-PC:~$ code -v
1.68.1
30d9c6cd9483b2cc586687151bcbcd635f373630
x64

FuXii@FuXii-PC:~$ clang -v
Debian clang version 15.0.0-++20220622102607+46be5faaf034-1~exp1~20220622222616.569
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Selected multilib: .;@m64

FuXii@FuXii-PC:~$ clangd --version
Debian clangd version 15.0.0-++20220622102607+46be5faaf034-1~exp1~20220622222616.569
Features: linux
Platform: x86_64-pc-linux-gnu

FuXii@FuXii-PC:~$ cmake --version
cmake version 3.18.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

the CMakelists.txt write in:

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED true)

and the code in source file: (the code is copy from cppreference)

#include <concepts>
#include <iostream>

template<typename T, typename ... U>
concept IsAnyOf = (std::same_as<T, U> || ...);

template<typename T>
concept IsPrintable = std::integral<T> || std::floating_point<T> ||
    IsAnyOf<std::remove_cvref_t<std::remove_pointer_t<std::decay_t<T>>>, char, wchar_t>;

void println(IsPrintable auto const ... arguments)
{
    (std::wcout << ... << arguments) << '\n';
}

int main() { println("Example: ", 3.14, " : ", 42, " : [", 'a', L'-', L"Z]"); }

then build:

/data/home/FuXii/Projects/Turbo/samples/CPPStandardTest.cpp:1:10: fatal error: 'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
1 error generated.
make[2]: *** [samples/CMakeFiles/CPPStandardTest.dir/build.make:82: samples/CMakeFiles/CPPStandardTest.dir/CPPStandardTest.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3322: samples/CMakeFiles/CPPStandardTest.dir/all] Error 2
make: *** [Makefile:171: all] Error 2
The terminal process "/usr/bin/bash '-c', 'make'" terminated with exit code: 2.
BertalanD commented 2 years ago

On Linux, Clang uses libstdc++ by default as the C++ standard library. Your distro comes with gcc/libstdc++ version 8 (see the "Found candidate GCC installation" lines), but the <concepts> header was only added in libstdc++ 10.

You can install a newer version of GCC or libc++, LLVM's own C++ standard library. To use libc++, ensure that CMake uses the Clang compiler (you might need to set CMAKE_CXX_COMPILER) and add the -stdlib=libc++ flag to CMAKE_CXX_FLAGS.

I'm closing this issue as it's not a problem with LLVM, but feel free to reply if you have questions.

FuXiii commented 2 years ago

When I try to search libstdc++ by apt, I can't find libstdc++ 10, which one should I download?:

FuXii@FuXii-PC:~$ sudo apt search libstdc++
Sorting... Done
Full Text Search... Done
lib32stdc++-7-dev/unknown 7.4.0-6 amd64
  GNU Standard C++ Library v3 (development files)

lib32stdc++-8-dev/unknown 8.3.0.3-3+rebuild amd64
  GNU Standard C++ Library v3 (development files)

lib32stdc++-8-dev-amd64-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files) (amd64)

lib32stdc++-8-dev-mips64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (mips64)

lib32stdc++-8-dev-mips64el-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files) (mips64el)

lib32stdc++-8-dev-mips64r6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (mips64r6)

lib32stdc++-8-dev-mips64r6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (mips64r6el)

lib32stdc++-8-dev-ppc64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (ppc64)

lib32stdc++-8-dev-s390x-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files) (s390x)

lib32stdc++-8-dev-sparc64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (sparc64)

lib32stdc++-8-dev-x32-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (x32)

lib32stdc++6-7-dbg/unknown 7.4.0-6 amd64
  GNU Standard C++ Library v3 (debugging files)

lib32stdc++6-8-dbg/unknown 8.3.0.3-3+rebuild amd64
  GNU Standard C++ Library v3 (debugging files)

lib64stdc++-7-dev/unknown 7.4.0-6 i386
  GNU Standard C++ Library v3 (development files)

lib64stdc++-8-dev/unknown 8.3.0.3-3+rebuild i386
  GNU Standard C++ Library v3 (development files)

lib64stdc++-8-dev-i386-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files) (i386)

lib64stdc++-8-dev-mips-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files) (mips)

lib64stdc++-8-dev-mipsel-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files) (mipsel)

lib64stdc++-8-dev-mipsr6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (mipsr6)

lib64stdc++-8-dev-mipsr6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (mipsr6el)

lib64stdc++-8-dev-powerpc-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (powerpc)

lib64stdc++-8-dev-x32-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (x32)

lib64stdc++6/unknown 8.3.0.3-3+rebuild i386
  GNU Standard C++ Library v3 (64bit)

lib64stdc++6-7-dbg/unknown 7.4.0-6 i386
  GNU Standard C++ Library v3 (debugging files)

lib64stdc++6-8-dbg/unknown 8.3.0.3-3+rebuild i386
  GNU Standard C++ Library v3 (debugging files)

lib64stdc++6-i386-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (64bit)

lib64stdc++6-mips-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (64bit)

lib64stdc++6-mipsel-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (64bit)

lib64stdc++6-mipsr6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (64bit)

lib64stdc++6-mipsr6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (64bit)

lib64stdc++6-powerpc-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (64bit)

lib64stdc++6-x32-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (64bit)

libc++-11-dev/unknown 1:11.0.1-2 amd64
  LLVM C++ Standard library (development files)

libc++-15-dev/unknown 1:15~++20220622102607+46be5faaf034-1~exp1~20220622222616.569 amd64
  LLVM C++ Standard library (development files)

libc++-7-dev/unknown,now 1:7.0.1-8 amd64 [installed,automatic]
  LLVM C++ Standard library (development files)

libc++-dev/unknown,now 1:7.0-47 amd64 [installed]
  LLVM C++ Standard library (development files)

libc++1/unknown 1:7.0-47 amd64
  LLVM C++ Standard library

libc++1-11/unknown 1:11.0.1-2 amd64
  LLVM C++ Standard library

libc++1-15/unknown 1:15~++20220622102607+46be5faaf034-1~exp1~20220622222616.569 amd64
  LLVM C++ Standard library

libc++1-7/unknown,now 1:7.0.1-8 amd64 [installed,automatic]
  LLVM C++ Standard library

libgmp-dev/unknown,now 2:6.1.2+dfsg.1-1 amd64 [installed,automatic]
  Multiprecision arithmetic library developers tools

libn32stdc++-8-dev-mips-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files) (mips)

libn32stdc++-8-dev-mips64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (mips64)

libn32stdc++-8-dev-mips64el-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files) (mips64el)

libn32stdc++-8-dev-mips64r6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (mips64r6)

libn32stdc++-8-dev-mips64r6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (mips64r6el)

libn32stdc++-8-dev-mipsel-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files) (mipsel)

libn32stdc++-8-dev-mipsr6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (mipsr6)

libn32stdc++-8-dev-mipsr6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files) (mipsr6el)

libn32stdc++6-mips-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (n32)

libn32stdc++6-mips64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (n32)

libn32stdc++6-mips64el-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (n32)

libn32stdc++6-mips64r6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (n32)

libn32stdc++6-mips64r6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (n32)

libn32stdc++6-mipsel-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (n32)

libn32stdc++6-mipsr6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (n32)

libn32stdc++6-mipsr6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (n32)

libstdc++-7-dev/unknown 7.4.0-6 amd64
  GNU Standard C++ Library v3 (development files)

libstdc++-7-doc/unknown,unknown 7.4.0-6 all
  GNU Standard C++ Library v3 (documentation files)

libstdc++-7-pic/unknown 7.4.0-6 amd64
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-dev/unknown,now 8.3.0.3-3+rebuild amd64 [installed,automatic]
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-alpha-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-amd64-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-arm64-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-armel-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-armhf-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-hppa-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-i386-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-m68k-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-mips-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-mips64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-mips64el-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-mips64r6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-mips64r6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-mipsel-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-mipsr6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-mipsr6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-powerpc-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-powerpcspe-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-ppc64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-ppc64el-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-riscv64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-s390x-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-sh4-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-sparc64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-dev-x32-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (development files)

libstdc++-8-doc/unknown,unknown 8.3.0.3-3+rebuild all
  GNU Standard C++ Library v3 (documentation files)

libstdc++-8-pic/unknown 8.3.0.3-3+rebuild amd64
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-alpha-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-amd64-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-arm64-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-armel-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-armhf-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-hppa-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-i386-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-m68k-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-mips-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-mips64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-mips64el-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-mips64r6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-mips64r6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-mipsel-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-mipsr6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-mipsr6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-powerpc-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-powerpcspe-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-ppc64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-ppc64el-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-riscv64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-s390x-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-sh4-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-sparc64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-8-pic-x32-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3 (shared library subset kit)

libstdc++-arm-none-eabi-newlib/unknown,unknown 15:7-2018-q2-5+12 all
  GNU Standard C++ Library v3 for ARM Cortex-R/M processors (newlib)

libstdc++5/unknown 1:3.3.6-30 amd64
  The GNU Standard C++ Library v3

libstdc++6/unknown,now 8.3.0.3-3+rebuild amd64 [installed]
  GNU Standard C++ Library v3

libstdc++6-7-dbg/unknown 7.4.0-6 amd64
  GNU Standard C++ Library v3 (debugging files)

libstdc++6-8-dbg/unknown 8.3.0.3-3+rebuild amd64
  GNU Standard C++ Library v3 (debugging files)

libstdc++6-alpha-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-amd64-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3

libstdc++6-arm64-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3

libstdc++6-armel-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3

libstdc++6-armhf-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3

libstdc++6-hppa-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-i386-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3

libstdc++6-m68k-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-mips-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3

libstdc++6-mips64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-mips64el-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3

libstdc++6-mips64r6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-mips64r6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-mipsel-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3

libstdc++6-mipsr6-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-mipsr6el-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-powerpc-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-powerpcspe-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-ppc64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-ppc64el-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3

libstdc++6-riscv64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-s390x-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3

libstdc++6-sh4-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-sparc64-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libstdc++6-x32-cross/unknown,unknown 8.3.0-2cross2 all
  GNU Standard C++ Library v3

libx32stdc++-7-dev/unknown 7.4.0-6 amd64
  GNU Standard C++ Library v3 (development files)

libx32stdc++-8-dev/unknown 8.3.0.3-3+rebuild amd64
  GNU Standard C++ Library v3 (development files)

libx32stdc++-8-dev-amd64-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files) (amd64)

libx32stdc++-8-dev-i386-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (development files) (i386)

libx32stdc++6/unknown 8.3.0.3-3+rebuild amd64
  GNU Standard C++ Library v3 (x32)

libx32stdc++6-7-dbg/unknown 7.4.0-6 amd64
  GNU Standard C++ Library v3 (debugging files)

libx32stdc++6-8-dbg/unknown 8.3.0.3-3+rebuild amd64
  GNU Standard C++ Library v3 (debugging files)

libx32stdc++6-amd64-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (x32)

libx32stdc++6-i386-cross/unknown,unknown 8.3.0-2cross1 all
  GNU Standard C++ Library v3 (x32)

FuXii@FuXii-PC:~$ 
FuXiii commented 2 years ago

I can find:

libc++-15-dev/unknown 1:15~++20220622102607+46be5faaf034-1~exp1~20220622222616.569 amd64
  LLVM C++ Standard library (development files)

Can I just download this one? or I should download some one like libstdc++10,but until now I can't find this one by apt.should I update the apt search source link?

BertalanD commented 2 years ago

Looks like only older versions of libstdc++ are available for your distribution. You might be able to get a newer one from the Debian unstable repos or by building it from source, but that seems like a lot of hassle. I think the easiest option is to use libc++-15-dev with Clang -stdlib=libc++.

FuXiii commented 2 years ago

Ok, I had download the libc++-15-dev and the stdc++ head path is /usr/lib/llvm-15/include/c++/v1, How to set this path let clang and clangd can find?

And head path clang will search is (the command I was find by google): clang++ -E -x c++ - -v < /dev/null

FuXii@FuXii-PC:/data/home/FuXii/Projects/Turbo$ clang++ -E -x c++ - -v < /dev/null
Debian clang version 15.0.0-++20220622102607+46be5faaf034-1~exp1~20220622222616.569
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Selected multilib: .;@m64
 (in-process)
 "/usr/lib/llvm-15/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -E -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -v -fcoverage-compilation-dir=/data/home/FuXii/Projects/Turbo -resource-dir /usr/lib/llvm-15/lib/clang/15.0.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward -internal-isystem /usr/lib/llvm-15/lib/clang/15.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir=/data/home/FuXii/Projects/Turbo -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o - -x c++ -
clang -cc1 version 15.0.0 based upon LLVM 15.0.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8
 /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
 /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward
 /usr/lib/llvm-15/lib/clang/15.0.0/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 403 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
FuXiii commented 2 years ago

Can I just run clang -I [the header path]? I just need run this command once or run once time per I run clang command?

tru commented 2 years ago

Can I just run clang -I [the header path]? I just need run this command once or run once time per I run clang command?

Just pass -stdlib=libc++ and it will handle the include paths.

llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-driver

FuXiii commented 2 years ago

image

then build output:

/usr/bin/ld: cannot find -lc++abi
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [samples/CMakeFiles/HelloTriangle.dir/build.make:227: samples/HelloTriangle] Error 1
make[1]: *** [CMakeFiles/Makefile2:3199: samples/CMakeFiles/HelloTriangle.dir/all] Error 2
make: *** [Makefile:171: all] Error 2
The terminal process "/usr/bin/bash '-c', 'make'" terminated with exit code: 2.

whar is c++abi?

BertalanD commented 2 years ago

libc++abi contains the low level parts of the C++ runtime. It's packaged for Debian/Deepin, just install the package and it will work.

FuXiii commented 2 years ago

apt can not find libc++abi package

FuXii@FuXii-PC:~$ sudo apt install libc++abi
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libc++abi
E: Couldn't find any package by regex 'libc++abi'

If I try to search libc++abi by dpkg:

FuXii@FuXii-PC:~$ dpkg -S libc++abi
libc++abi1-15:amd64: /usr/share/doc/libc++abi1-15/copyright
libc++abi1-15:amd64: /usr/share/lintian/overrides/libc++abi1-15
libc++abi1-15:amd64: /usr/share/doc/libc++abi1-15/NEWS.Debian.gz
libc++abi1-15:amd64: /usr/lib/llvm-15/lib/libc++abi.so.1
libc++abi1-15:amd64: /usr/lib/x86_64-linux-gnu/libc++abi.so.1.0
libc++abi1-15:amd64: /usr/lib/x86_64-linux-gnu/libc++abi.so.1
libc++abi1-15:amd64: /usr/share/doc/libc++abi1-15
libc++abi1-15:amd64: /usr/lib/llvm-15/lib/libc++abi.so.1.0
libc++abi1-15:amd64: /usr/share/doc/libc++abi1-15/changelog.Debian.gz

should I follow the https://libcxx.llvm.org/BuildingLibcxx.html to build the libc++?