# Linker error with CXX\_MODULES

**URL:** https://discourse.cmake.org/t/linker-error-with-cxx-modules/15449
**Category:** Development
**Tags:** os:windows, gen:ninja
**Created:** [January 9, 2026, 7:27pm UTC](https://discourse.cmake.org/t/linker-error-with-cxx-modules/15449 "2026-01-09T19:27:20Z")
**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: [January 9, 2026, 7:27pm UTC](https://discourse.cmake.org/t/linker-error-with-cxx-modules/15449/1 "2026-01-09T19:27:20Z")

</div>

I have a project that build `Boost` with **CXX\_MODULES**. It works on `Linux` and `OSX`, but not on windows?

The `type_index` lib is a header only module the `any` lib too. The `any` module itself imports the `type_index`.

```bash
[367/557] Linking CXX shared library bin\boost_type_index-vc143-mt-x64-1_90.dll
[368/557] Generating CXX dyndep file examples\CMakeFiles\ExampleAny.dir\CXX.dd
[369/557] Generating CXX dyndep file examples\CMakeFiles\ExampleRegex.dir\CXX.dd
[370/557] Generating CXX dyndep file examples\CMakeFiles\ExampleAsio.dir\CXX.dd
[371/557] Generating CXX dyndep file examples\CMakeFiles\ExampleTest.dir\CXX.dd
[372/557] Linking CXX shared library bin\boost_any-vc143-mt-x64-1_90.dll
FAILED: [code=4294967295] bin/boost_any-vc143-mt-x64-1_90.dll lib/boost_any-vc143-mt-x64-1_90.lib 
C:\Windows\system32\cmd.exe /C "cd . && D:\a\_temp\1869045051\cmake-4.2.1-windows-x86_64\bin\cmake.exe -E vs_link_dll --msvc-ver=1944 --intdir=_deps\boost-build\libs\any\CMakeFiles\boost_any.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\x64\mt.exe --manifests -- C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\link.exe /nologo _deps\boost-build\libs\any\CMakeFiles\boost_any.dir\modules\boost_any.cppm.obj /out:bin\boost_any-vc143-mt-x64-1_90.dll /implib:lib\boost_any-vc143-mt-x64-1_90.lib /pdb:bin\boost_any-vc143-mt-x64-1_90.pdb /dll /version:1.90 -machine:x64 /INCREMENTAL:NO lib\boost_type_index-vc143-mt-x64-1_90.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK: command "C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\link.exe /nologo _deps\boost-build\libs\any\CMakeFiles\boost_any.dir\modules\boost_any.cppm.obj /out:bin\boost_any-vc143-mt-x64-1_90.dll /implib:lib\boost_any-vc143-mt-x64-1_90.lib /pdb:bin\boost_any-vc143-mt-x64-1_90.pdb /dll /version:1.90 -machine:x64 /INCREMENTAL:NO lib\boost_type_index-vc143-mt-x64-1_90.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST:EMBED,ID=2" failed (exit code 1181) with the following output:
LINK : fatal error LNK1181: cannot open input file 'lib\boost_type_index-vc143-mt-x64-1_90.lib'

```

The code is here: [Bump version: 1.90.0-dev1 by ClausKlein · Pull Request #11 · ClausKlein/boost-cmake · GitHub](https://github.com/ClausKlein/boost-cmake/pull/11)

---

<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: [January 10, 2026, 3:13am UTC](https://discourse.cmake.org/t/linker-error-with-cxx-modules/15449/2 "2026-01-10T03:13:30Z")

</div>

Try `-DBOOST_ALL_NO_LIB`? Though the library is directly on the command line, so autolinking is unlikely the direct cause…

Oh…this is building Boost _itself_! The lack of a `.lib` usually means that the DLL is not exporting any symbols from it. The linker only makes a `.lib` if the DLL exports symbols.

---

<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: [January 10, 2026, 4:33am UTC](https://discourse.cmake.org/t/linker-error-with-cxx-modules/15449/3 "2026-01-10T04:33:20Z")

</div>

Both libs are `header only` build as CXX\_MODULES

```bash
bash-5.3$ dyld_info libboost_type_index.1.90.0.dylib
libboost_type_index.1.90.0.dylib [x86_64]:
    -platform:
        platform minOS sdk
           macOS 14.0 14.0   
    -segments:
        load-offset segment section sect-size seg-size perm
        0x00000000 __TEXT 8KB r.x
        0x00001F10 __text 70
        0x00001F56 __stubs 12
        0x00001F62 __const 57
        0x00001F9C __unwind_info 96
        0x00002000 __DATA_CONST 4KB rw.
        0x00002000 __got 16
        0x00002010 __const 64
    -dependents:
        attributes load path
                       /usr/local/opt/llvm/lib/c++/libc++abi.1.dylib
                       /usr/local/opt/llvm/lib/c++/libc++.1.dylib
                       /usr/lib/libSystem.B.dylib
bash-5.3$ dyld_info libboost_any.1.90.0.dylib
libboost_any.1.90.0.dylib [x86_64]:
    -platform:
        platform minOS sdk
           macOS 14.0 14.0   
    -segments:
        load-offset segment section sect-size seg-size perm
        0x00000000 __TEXT 8KB r.x
        0x00001BD0 __text 768
        0x00001ED0 __stubs 12
        0x00001EDC __cstring 61
        0x00001F19 __const 119
        0x00001F90 __unwind_info 112
        0x00002000 __DATA_CONST 4KB rw.
        0x00002000 __got 24
        0x00002018 __const 192
    -dependents:
        attributes load path
                       /usr/local/opt/llvm/lib/c++/libc++abi.1.dylib
                       /usr/local/opt/llvm/lib/c++/libc++.1.dylib
                       @rpath/libboost_type_index.1.90.0.dylib
                       /usr/lib/libSystem.B.dylib
bash-5.3$ dyld_info libboost_a.1.90.0.dylib
libboost_any.1.90.0.dylib libboost_any.dylib libboost_atomic.1.90.0.dylib libboost_atomic.dylib         
bash-5.3$ dyld_info libboost_atomic.1.90.0.dylib
libboost_atomic.1.90.0.dylib [x86_64]:
    -platform:
        platform minOS sdk
           macOS 14.0 14.0   
    -segments:
        load-offset segment section sect-size seg-size perm
        0x00000000 __TEXT 12KB r.x
        0x00002010 __text 3370
        0x00002D3A __stubs 126
        0x00002DB8 __gcc_except_tab 284
        0x00002ED4 __unwind_info 296
        0x00003000 __DATA_CONST 4KB rw.
        0x00003000 __got 184
        0x00004000 __DATA 36KB rw.
        0x00004000 __data 32776
        0x0000C008 __bss 1
    -dependents:
        attributes load path
                       /usr/local/opt/llvm/lib/c++/libc++abi.1.dylib
                       /usr/local/opt/llvm/lib/c++/libc++.1.dylib
                       /usr/lib/libSystem.B.dylib
bash-5.3$ 

```

see too [Header-only libraries and C++20 modules](https://discourse.cmake.org/t/header-only-libraries-and-c-20-modules/10680)

and [type\_index/modules/boost\_type\_index.cppm at develop · boostorg/type\_index · GitHub](https://github.com/boostorg/type_index/blob/develop/modules/boost_type_index.cppm)

---

<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: [January 10, 2026, 10:29am UTC](https://discourse.cmake.org/t/linker-error-with-cxx-modules/15449/4 "2026-01-10T10:29:02Z")

</div>

If I build static libs on Windows, it works:

> <https://github.com/ClausKlein/boost-cmake/pull/11/commits/c2605a39b0037c79536cb3a46d90145eb7c99aac>
>
> This should prevent link errors with header only modules

---

<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: [January 12, 2026, 12:33am UTC](https://discourse.cmake.org/t/linker-error-with-cxx-modules/15449/5 "2026-01-12T00:33:14Z")

</div>

Modules provide a “module initialization symbol” that imports call. This is how modules are able to order global static initializations.

There’s been talk of an attribute one can use (`export module x [[module_noinit]];` or something) to say "this module pinky swears to need no global static initialization (even transitively). which would allow importers to skip calling it. It hasn’t gone anywhere yet (not even a paper).

Until then, all named module providers must provide some kind of library artifact to provide such symbols.
