This example will compile the std module using the official gcc docker image.
Make sure you have docker installed and the latest gcc image:
docker pull gccFirst run a shell inside a gcc container:
docker run -it --rm gcc /bin/bashYour will be greeted by a shell prompt from inside the container. Run the following to get the path for std.cc:
find /usr -name std.cc
exitIn the next setion we'll assume the path you got was /usr/local/include/c++/15.2.0/bits/std.cc
Now that you know the location of std.cc you can compile it with:
docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app gcc bash -c "
mkdir -p gcm.cache && chmod 755 gcm.cache && \
g++ -std=c++23 -fmodules-ts -c /usr/local/include/c++/15.2.0/bits/std.cc && \
rm std.o
"You can also use the provided docker_cmp-std.sh script, but make sure the correct path is used.
The std.gcm file will be located in your current directory inside the folder gcm.cache.
To compile and run the sample program use the provided ./docker_run.sh script.
It will compile main.cpp as follows:
g++ -std=c++23 -fmodules-ts main.cpp -o myApp