i cant run c++ modules using wsl2


i am trying to basic module code, but i keep getting this error



here are my same code 

#include <iostream>
export module maths;      // (2)

export int add(int fir, int sec){
    return fir + sec;

#include <iostream>

import maths;                        // (1)

int main() {
    std::cout << "Hello, World!" << std::endl;
    std::cout << add(1, 2) << std::endl;
    return 0;


C++ 20 named modules are supported in CMake 3.28 and newer when using  Ninja and Visual Studio Generators (VS 2022 and newer in combination with the MSVC 14.34 toolset, provided with VS 17.4, and newer), LLVM/Clang 16.0 and newer, and GCC 14 (after the 2023-09-20 daily bump) and newer.

  1. Do you have set(CMAKE_CXX_STANDARD 20) in your CMakeLists.txt?
  2. What compiler (name and version) is installed inside the WSL instance? Does it meet the requirements above?
  3. Please install Ninja inside the WSL instance and select the Ninja generator in File | Settings | Build, Execution, Deployment | CMake in CLion.