# file not found error: /lib/share/libc++/v1/std.cppm with Clang 21.1.7 on Linux

**URL:** https://discourse.cmake.org/t/file-not-found-error-lib-share-libc-v1-std-cppm-with-clang-21-1-7-on-linux/15368
**Category:** Development
**Tags:** os:linux, gen:ninja
**Created:** [December 6, 2025, 10:17pm UTC](https://discourse.cmake.org/t/file-not-found-error-lib-share-libc-v1-std-cppm-with-clang-21-1-7-on-linux/15368 "2025-12-06T22:17:45Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [December 6, 2025, 10:17pm UTC](https://discourse.cmake.org/t/file-not-found-error-lib-share-libc-v1-std-cppm-with-clang-21-1-7-on-linux/15368/1 "2025-12-06T22:17:45Z")

</div>

```bash
clang++ --version
Ubuntu clang version 21.1.7 (++20251127113503+9ed1927442a4-1~exp1~20251127113518.64)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-21/bin
clang++ -print-file-name=libc++.modules.json
/lib/x86_64-linux-gnu/libc++.modules.json
clang++ -print-file-name=libstdc++.modules.json
libstdc++.modules.json
cmake --version
cmake version 4.2.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).
ninja --version
1.13.0
cmake --preset dev --fresh --log-level=VERBOSE
CMake Warning (dev) at cmake/prelude.cmake:58 (if):
Preset CMake variables:

  BUILD_MCSS_DOCS:BOOL="FALSE"
  BUILD_SHARED_LIBS:BOOL="TRUE"
  CMAKE_BUILD_TYPE="Release"
  CMAKE_CONFIGURATION_TYPES="RelWithDebInfo;Release;Debug"
  CMAKE_CXX_EXTENSIONS:BOOL="TRUE"
  CMAKE_CXX_FLAGS_DEBUG="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wno-conversion -Wno-sign-conversion -Wcast-qual -Wformat=2 -Wundef -Wno-float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wno-implicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wno-old-style-cast"
  CMAKE_CXX_STANDARD="23"
  CMAKE_CXX_STANDARD_REQUIRED:BOOL="TRUE"
  CMAKE_EXE_LINKER_FLAGS_DEBUG="-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now"
  CMAKE_EXPORT_COMPILE_COMMANDS:BOOL="TRUE"
  CMAKE_INSTALL_PREFIX:PATH="/__w/cmake-init-modules/cmake-init-modules/stagedir"
  uninitialized variable 'CMAKE_CXX_STDLIB_MODULES_JSON'
Call Stack (most recent call first):
  CMakeLists.txt:4 (include)
This warning is for project developers. Use -Wno-dev to suppress it.

  CMAKE_MESSAGE_LOG_LEVEL="VERBOSE"
  CMAKE_PREFIX_PATH:STRING="/__w/cmake-init-modules/cmake-init-modules/stagedir"
  CMAKE_SHARED_LINKER_FLAGS_DEBUG="-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now"
  CMAKE_VERIFY_INTERFACE_HEADER_SETS:BOOL="TRUE"
  cmake-init-modules_DEVELOPER_MODE:BOOL="TRUE"

Preset environment variables:

  CPM_USE_LOCAL_PACKAGES="OFF"

-- CXXFLAGS=-stdlib=libc++
-- The CXX compiler identification is Clang 21.1.7
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
CMake Warning (dev) at /github/home/cmake/cmake-4.2.0-linux-x86_64/share/cmake-4.2/Modules/Compiler/CMakeCommonCompilerMacros.cmake:248 (cmake_language):
  CMake's support for `import std;` in C++23 and newer is experimental. It
  is meant only for experimentation and feedback to CMake developers.
Call Stack (most recent call first):
  /github/home/cmake/cmake-4.2.0-linux-x86_64/share/cmake-4.2/Modules/CMakeDetermineCompilerSupport.cmake:113 (cmake_create_cxx_import_std)
  /github/home/cmake/cmake-4.2.0-linux-x86_64/share/cmake-4.2/Modules/CMakeTestCXXCompiler.cmake:83 (CMAKE_DETERMINE_COMPILER_SUPPORT)
  CMakeLists.txt:7 (project)
This warning is for project developers. Use -Wno-dev to suppress it.

-- Detecting CXX compile features - done
-- CMAKE_CXX_COMPILER_IMPORT_STD=23;26
-- CMAKE_CXX_MODULE_STD=ON
-- ALGO_USE_MODULES=ON
-- CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=/usr/lib/llvm-21/include/c++/v1;/usr/lib/llvm-21/lib/clang/21/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
CMake Error at /__w/cmake-init-modules/cmake-init-modules/build/dev/CMakeFiles/4.2.0/CMakeCXXCompiler.cmake:111 (target_sources):
  Cannot find source file:

    /lib/share/libc++/v1/std.cppm
Call Stack (most recent call first):
  /__w/cmake-init-modules/cmake-init-modules/build/dev/CMakeFiles/CMakeScratch/TryCompile-mFgvN7/CMakeLists.txt:2 (project)

CMake Error at /__w/cmake-init-modules/cmake-init-modules/build/dev/CMakeFiles/4.2.0/CMakeCXXCompiler.cmake:103 (add_library):
  No SOURCES given to target: __cmake_cxx23
Call Stack (most recent call first):
  /__w/cmake-init-modules/cmake-init-modules/build/dev/CMakeFiles/CMakeScratch/TryCompile-mFgvN7/CMakeLists.txt:2 (project)

CMake Error at /__w/cmake-init-modules/cmake-init-modules/build/dev/CMakeFiles/4.2.0/CMakeCXXCompiler.cmake:127 (add_library):
  No SOURCES given to target: __cmake_cxx26
Call Stack (most recent call first):
  /__w/cmake-init-modules/cmake-init-modules/build/dev/CMakeFiles/CMakeScratch/TryCompile-mFgvN7/CMakeLists.txt:2 (project)

CMake Error at /github/home/cmake/cmake-4.2.0-linux-x86_64/share/cmake-4.2/Modules/Internal/CheckSourceCompiles.cmake:104 (try_compile):
  Failed to generate test project build system.
Call Stack (most recent call first):
  /github/home/cmake/cmake-4.2.0-linux-x86_64/share/cmake-4.2/Modules/Internal/CheckCompilerFlag.cmake:18 (cmake_check_source_compiles)
  /github/home/cmake/cmake-4.2.0-linux-x86_64/share/cmake-4.2/Modules/CheckCompilerFlag.cmake:124 (cmake_check_compiler_flag)
  /github/home/cmake/cmake-4.2.0-linux-x86_64/share/cmake-4.2/Modules/GenerateExportHeader.cmake:515 (check_compiler_flag)
  /github/home/cmake/cmake-4.2.0-linux-x86_64/share/cmake-4.2/Modules/GenerateExportHeader.cmake:693 (_test_compiler_hidden_visibility)
  CMakeLists.txt:43 (generate_export_header)

-- Configuring incomplete, errors occurred!
make: *** [GNUmakefile:58: .init] Error 1
Error: Process completed with exit code 2.

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 9, 2026, 4:01am UTC](https://discourse.cmake.org/t/file-not-found-error-lib-share-libc-v1-std-cppm-with-clang-21-1-7-on-linux/15368/2 "2026-02-09T04:01:14Z")

</div>

It looks like the toolchain’s JSON file doesn’t specify sources correctly. I’d need the layout of the toolchain and its `modules.json` file to be able to do anything more.

---

<div class="post-metadata">

### Author: ![Fedor\_Osetrov](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fedor_osetrov/32/6010_2.png) [@Fedor\_Osetrov](https://discourse.cmake.org/u/Fedor_Osetrov)
#### Post date: [May 22, 2026, 12:09pm UTC](https://discourse.cmake.org/t/file-not-found-error-lib-share-libc-v1-std-cppm-with-clang-21-1-7-on-linux/15368/3 "2026-05-22T12:09:48Z")

</div>

Hi @ben.boeckel ! I see the same problems for clang since 22.1.6, cmake 4.3.2, and llvm Ubuntu 24.04 debian packages

The files layout is  
`std.pcm` installed into `/usr/lib/llvm-22/share/libc++/v1/std.cppm`  
`libc++.modules.json` is installed (from `libc++-22-dev` package) into `/usr/lib/x86_64-linux-gnu/libc++.modules.json` and `/usr/lib/llvm-22/lib/libc++.modules.json` (the symlink to first path)

`clang++-22 -print-file-name=libc++.modules.json` output is `/lib/x86_64-linux-gnu/libc++.modules.json`

the libc++.modules.json contents is

```json
{
  "version": 1,
  "revision": 1,
  "modules": [
    {
      "logical-name": "std",
      "source-path": "../share/libc++/v1/std.cppm",
      "is-std-library": true,
      "local-arguments": {
        "system-include-directories": [
          "../share/libc++/v1"
        ]
      }
    },
    {
      "logical-name": "std.compat",
      "source-path": "../share/libc++/v1/std.compat.cppm",
      "is-std-library": true,
      "local-arguments": {
        "system-include-directories": [
          "../share/libc++/v1"
        ]
      }
    }
  ]
}

```

I guess CMake try to find std.cppm relative to `/lib/x86_64-linux-gnu/libc++.modules.json` directory and come up with `/lib/share/libc++/v1/std.compat.cppm` which does not exist

The solution (since CMake 4.2) is to explicitly set `-DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-22/lib/libc++.modules.json`  
But I am not sure the solution is intended because `import std` does not work by default

Do you know whether it is a CMake problem or clang or llvm debian package?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 25, 2026, 3:17am UTC](https://discourse.cmake.org/t/file-not-found-error-lib-share-libc-v1-std-cppm-with-clang-21-1-7-on-linux/15368/4 "2026-05-25T03:17:34Z")

</div>

I feel like packaging…but LLVM might need to handle multi-arch layouts and recompute the number of `../` bits to use. But not reporting `/usr` seems like either a UsrMove issue (e.g., still putting `/bin` in `PATH`) or a packaging problem with specifying the prefix properly.

---

<div class="post-metadata">

### Author: ![vito.gamberini](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vito.gamberini/32/4376_2.png) [@vito.gamberini](https://discourse.cmake.org/u/vito.gamberini)
#### Post date: [June 29, 2026, 6:14pm UTC](https://discourse.cmake.org/t/file-not-found-error-lib-share-libc-v1-std-cppm-with-clang-21-1-7-on-linux/15368/5 "2026-06-29T18:14:02Z")

</div>

You cannot symlink to a file format which is specified to provide paths relative to the file itself, unless the paths it refers to also have symlinks in the correct relative location.

This is a packaging problem. The paths need to be rewritten to absolutes if they want this to work.
