r/cpp • • Aug 18 '21

C++20 modules with GCC11

https://blog.feabhas.com/2021/08/c20-modules-with-gcc11/
222 Upvotes

59 comments sorted by

View all comments

3

u/lieddersturme Aug 18 '21 edited Aug 19 '21

Thanks of this, now I am trying to install gcc 11 in Ubuntu, but I cant.

Edit: I solve it, compiling GCC 11, but I cant use modules with cmake.

2

u/feabhas Aug 20 '21

See the github repo linked. I have CMake build there. The main thing I found will GCC11 is that file ordering where modules are separated into two files is important. I haven't yet worked out the best way to get header-only headers to build for module import.

1

u/lieddersturme Aug 20 '21

Hi.

I've tried this: https://github.com/feabhas/Cpp20-Modules-getting-started/tree/main/part7

But does not work:

[1/4] Building CXX object CMakeFiles/Application.dir/func.cxx.o
FAILED: CMakeFiles/Application.dir/func.cxx.o
/bin/g++ -g -std=c++20 -fmodules-ts -MD -MT CMakeFiles/Application.dir/func.cxx.o -MF CMakeFiles/Application.dir/func.cxx.o.d -o CMakeFiles/Application.dir/func.cxx.o -c ../func.cxx
[3/4] Building CXX object CMakeFiles/Application.dir/func_impl.cxx.o
ninja: build stopped: subcommand failed.

I am on Ubuntu, cmake 3.18.4 and GCC 11.2