Module Mapper File on gcc 15 c++23: what am I doing wrong?
Igor Machado
igor.machado@gmail.com
Thu Mar 20 01:11:25 GMT 2025
Hello, I work on Ubuntu wih gcc 15.
I searched for specific information on module mapper file, but couldn't
find much on the Internet... I read the official document, also the
documentation, some links like
https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Module-Mapper.html, but
still cannot understand properly this issue.
Some people also mentioned a g++-mapper-server, but I couldn't find it on
gcc-15 on ubuntu (https://github.com/michigan-musicer/modules-demo).
It seems the same problem as this (
https://github.com/msys2/MINGW-packages/issues/12797), but it didn't seem
to be solved, although old.
Sorry if that's documented somewhere.
I manage to make the example work with CMake 4.0, but cannot do it manually
with mapper file.
I have two files: main.cpp, that does "import std; import hello;" and
hello.cppm, which does "export module hello;" and "import std;"
These are organized as example/hello-world/main.cpp and
example/hello-world/hello.cppm, and then, I manage to compile std module
and generate example/hello-world/gcm.cache/std.gcm.
I have a limitation that I cannot run g++ command directly inside the
folder containing gcm.cache, so I created a
example/hello-world/gcm.cache/mapper.txt file with the following content:
std gcm.cache/std.gcm
Then, I try to compile as follows (trying to generate hello.gcm):
g++-15 - -fmodules '-std=c++23' -c example/hello-world/hello.cppm
-fmodule-mapper=example/hello-world/mapper.txt
But then, it complains of 'hello' module:
example/hello-world/hello.cppm:3:8: fatal error: unknown compiled module
interface: no such module
3 | export module hello;
If I go inside the folder example/hello-world/ and run g++ command with
module-mapper, then it works fine, because it already searches for
gcm.cache/ folder automatically... however, my process cannot run inside
that folder, so do I really need a module mapper file or something else?
Complete files:
main.cc
// main.cc
import hello;
import std;
int main() {
say_hello("world");
return 0;
}
hello.cppm
// hello.cppm
export module hello;
import std;
export inline void say_hello(std::string_view const &name)
{
std::cout << "Hello " << name << "!\n";
}
Best regards and sorry for the inconvenience.
Igor Machado
More information about the Gcc-help
mailing list