Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22248

import std module with gcc-15

$
0
0

As mention in this gcc patches, the std module is built in gcc development branch. I build from source and try to use it in cmake project but it show std module not found.

This is my minimal example:

cmake_minimum_required(VERSION 3.30 FATAL_ERROR)set(CMAKE_CXX_STANDARD 23)if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.30)    set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "0e5b6991-d74f-4b3d-a41c-cf096e0b2508")endif()set(CMAKE_CXX_STANDARD_REQUIRED OFF)set(CMAKE_CXX_MODULE_STD 1)project(module-test VERSION 0.1.0 LANGUAGES CXX)add_executable(module-test main.cpp)target_link_options(module-test PRIVATE -L/home/leenhawk/tools/gcc/lib -Wl,-rpath,/home/leenhawk/tools/gcc/lib)set(CMAKE_VERBOSE_MAKEFILE ON)
import std;int main(int, char**){    std::cout << "Hello, from module-test!\n";}

I have found libstdc++.module.json in the ~/tools/gcc/lib, how to use it?

The teminal output:

cmake] CMake Error in CMakeLists.txt:[cmake]   The "CXX_MODULE_STD" property on the target "module-test" requires that the[cmake]   "__CMAKE::CXX23" target exist, but it was not provided by the toolchain.[cmake]   Reason:[cmake] [cmake]     Toolchain does not support discovering `import std` support[cmake] [cmake] [cmake] -- Generating done (0.0s)

I use CMake 3.31.1. And there is command line:

/home/leenhawk/tools/gcc/bin/g++ main.cpp -L/home/leenhawk/tools/gcc/lib -Wl,-rpath,/home/leenhawk/tools/gcc/lib -std=c++2b  -fmodules-ts
In module imported at main.cpp:1:1:std: error: failed to read compiled module: No such file or directorystd: note: compiled module file is ‘gcm.cache/std.gcm’std: note: imports must be built before being importedstd: fatal error: returning to the gate for a mechanical issuecompilation terminated.

Viewing all articles
Browse latest Browse all 22248

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>