# Unable to build Eigen & OpenXLSX on windows

**URL:** https://discourse.cmake.org/t/unable-to-build-eigen-openxlsx-on-windows/10868
**Category:** Code
**Tags:** os:windows
**Created:** [May 17, 2024, 5:54pm UTC](https://discourse.cmake.org/t/unable-to-build-eigen-openxlsx-on-windows/10868 "2024-05-17T17:54:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Shepard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/shepard/32/4416_2.png) [@Shepard](https://discourse.cmake.org/u/Shepard)
#### Post date: [May 17, 2024, 5:54pm UTC](https://discourse.cmake.org/t/unable-to-build-eigen-openxlsx-on-windows/10868/1 "2024-05-17T17:54:40Z")

</div>

Well, I’m working on a C++ project where I am using linear algebra from Eigen.

This is how I fetch the Eigen library from my root `CmakeLists.txt`:

```
message([STATUS] "Fetching eigen.")
block(SCOPE_FOR VARIABLES)
    set(EIGEN_BUILD_TESTING OFF)
    set(EIGEN_BUILD_PKGCONFIG OFF)
    set(EIGEN_BUILD_DOC OFF)
    FetchContent_Declare(
            Eigen
            GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
            GIT_TAG 3.4
            GIT_SHALLOW TRUE
            GIT_PROGRESS TRUE
    )
    FetchContent_MakeAvailable(Eigen)
endblock()

```

I then have github actions to build and test on both ubuntu-22.04 and windows-latest.

The instructions to build on windows are (copied only until build starts):

```
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: CMake build and test on Windows

on:
  push:
    branches: ["master"]
  pull_request:
    branches: ["master"]

env:
  # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
  BUILD_TYPE: Release

jobs:
  build:
    name: build and test
    # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
    # You can convert this to a matrix build if you need cross-platform coverage.
    # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v4

      - name: Set reusable strings
        id: strings
        shell: bash
        run: |
          echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
          echo "bin-output-dir=${{ github.workspace }}/bin" >> "$GITHUB_OUTPUT"

      - name: Configure CMake
        run: >
          cmake -B ${{ steps.strings.outputs.build-output-dir }}
          -DCMAKE_CXX_COMPILER=msvc
          -DCMAKE_C_COMPILER=msvc
          -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
          -S ${{ github.workspace }}

```

## Problem

The linux build is successful, but the windows build fails with a slightly unexpected error already at the “Configure CMake” step. The error says:

```
[STATUS]Fetching pugixml.
[STATUS]Fetching eigen.
-- The C compiler identification is MSVC 19.39.33523.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test EIGEN_COMPILER_SUPPORT_CPP11
-- Performing Test EIGEN_COMPILER_SUPPORT_CPP11 - Failed
-- Performing Test COMPILER_SUPPORT_std=cpp03
-- Performing Test COMPILER_SUPPORT_std=cpp03 - Failed
-- Performing Test standard_math_library_linked_to_automatically
-- Performing Test standard_math_library_linked_to_automatically - Failed
-- Performing Test standard_math_library_linked_to_as_m
-- Performing Test standard_math_library_linked_to_as_m - Failed
CMake Error at build/_deps/eigen-src/CMakeLists.txt:136 (message):
  Can't link to the standard math library. Please report to the Eigen
  developers, telling them about your platform.

-- Configuring incomplete, errors occurred!
Error: Process completed with exit code 1.

```

What anybody have clue?

### Note:

This used to compile before I added [OpenXLSX](https://github.com/troldal/OpenXLSX) to the project as a submodule. Now it does not. The OpenXLSX library should be able to be built with msvc (which I am using), according to the official readme.

This is really weird to me.

Would it maybe help if I obtained all my packages with CPM ([GitHub - cpm-cmake/CPM.cmake: 📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.](https://github.com/cpm-cmake/CPM.cmake)) ?

### Additional question:

What is the preffered modern approach? To use CMake and fetch content or gitlab submodules?

---

<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: [March 4, 2025, 9:25am UTC](https://discourse.cmake.org/t/unable-to-build-eigen-openxlsx-on-windows/10868/2 "2025-03-04T09:25:17Z")

</div>

Do the projects build on their own, outside of `FetchContent`? If not, that sounds like an issue to ask upstream about.

---

<div class="post-metadata">

### Author: ![Lars](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/74df32/32.png) [@Lars](https://discourse.cmake.org/u/Lars)
#### Post date: [March 19, 2026, 11:27am UTC](https://discourse.cmake.org/t/unable-to-build-eigen-openxlsx-on-windows/10868/3 "2026-03-19T11:27:22Z")

</div>

> [@Shepard](#):
>
> This used to compile before I added [OpenXLSX](https://github.com/troldal/OpenXLSX) to the project as a submodule.

Hi @Shepard

I just stumbled upon your issue from 2024 after registering here - I am one of the maintainers for OpenXLSX - are you still using the library?

I have done a major rework on the CMake interface and am currently trying to ensure it also behaves well on Windows. If you still have a use for it, I would like to invite you to try the latest configuration in the cmake-unstable branch at

> **[GitHub - troldal/OpenXLSX at cmake-unstable](https://github.com/troldal/OpenXLSX/tree/cmake-unstable)**
>
> A C++ library for reading, writing, creating and modifying Microsoft Excel® (.xlsx) files. - troldal/OpenXLSX

If there’s anything I can integrate in the CMake configuration that makes your life easier with CPM, now would be the time to tell me about it 🙂

Kind regards

Lars
