# Struggling to Link Custom-Built libc++ with Modules Across Platforms

**URL:** https://discourse.cmake.org/t/struggling-to-link-custom-built-libc-with-modules-across-platforms/14401
**Category:** Usage
**Created:** [July 21, 2025, 10:52am UTC](https://discourse.cmake.org/t/struggling-to-link-custom-built-libc-with-modules-across-platforms/14401 "2025-07-21T10:52:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mccakit](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mccakit/32/5628_2.png) [@mccakit](https://discourse.cmake.org/u/mccakit)
#### Post date: [July 21, 2025, 10:52am UTC](https://discourse.cmake.org/t/struggling-to-link-custom-built-libc-with-modules-across-platforms/14401/1 "2025-07-21T10:52:29Z")

</div>

I already have a sysroot or SDK set up for each platform, but they either lack libc++, have an outdated version, or don’t include C++ standard library modules.

I want to build and statically link libc++ myself, so I can use modern C++ features (including modules) across all platforms I target—desktop, mobile, and embedded.

I’m familiar with building LLVM from source, and I understand building libc++ should be similar, just without the other runtimes and projects.

Assume I’ve done that for each target platform, so now I have several separate libc++ directories—one per target.

The problem is: how do I integrate these into my toolchains correctly? Simply adding the library and include directories doesn’t seem to be enough. For example, CMake fails to find libc++.modules.json, even when it’s located inside the lib directory I added.

When compiling natively, clang finds libc++ automatically, but this isn’t happening for cross-compilation.

So:  
How can I properly link my custom-built libc++ into each toolchain so CMake and Clang can use it—including module support—during cross-compilation?
