public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Building Standard Library Header units
@ 2020-12-21 12:03 Patrick Kox
  2020-12-21 17:28 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Kox @ 2020-12-21 12:03 UTC (permalink / raw)
  To: gcc-help

Hi all,
n00b here.

I'm trying to compile the examples used by the book Beginning C++20 (by
Horton and Van Weert) but the "import <iostream>;" part gives me
errors.

I've done some searching, and found out that I need a non-default
version of gcc (10 or 11) with support for Modules.

I've installed gcc-11 as indicated on the Wiki page
(https://gcc.gnu.org/wiki/cxx-modules) and the example code there works
fine.

Now when I use g++ -fmodules-ts Ex1_01.cpp I get the following error:
In module imported at Ex1_01.cpp:3:1:
/usr/local/include/c++/11.0.0/iostream: error: failed to read compiled
module: No such file or directory
/usr/local/include/c++/11.0.0/iostream: note: compiled module file is
‘gcm.cache/./usr/local/include/c++/11.0.0/iostream.gcm’
/usr/local/include/c++/11.0.0/iostream: note: imports must be built
before being imported
/usr/local/include/c++/11.0.0/iostream: fatal error: returning to the
gate for a mechanical issue
compilation terminated.
THIS IS AN IN-DEVELOPMENT COMPILER, it ate something that didn't agree
with it
See <https://gcc.gnu.org/wiki/cxx-modules#Bugs>, WHICH IS NOT THE USUAL
REPORTING MECHANISM!

After some more searching I've found this website:
https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Modules.html

which says the following:
The Standard Library is not provided as importable header units. If you
want to import such units, you must explicitly build them first.

So, my problem/question is:
How do I do this?
The only thing I can find is that the -fmodule-header flag should be
used, but not howto build a Header unit.

Patrick


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Building Standard Library Header units
  2020-12-21 12:03 Building Standard Library Header units Patrick Kox
@ 2020-12-21 17:28 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2020-12-21 17:28 UTC (permalink / raw)
  To: patrick.kox; +Cc: gcc-help

On Mon, 21 Dec 2020, 12:07 Patrick Kox, <patrick.kox@commandoregel.be>
wrote:

> Hi all,
> n00b here.
>
> I'm trying to compile the examples used by the book Beginning C++20 (by
> Horton and Van Weert) but the "import <iostream>;" part gives me
> errors.
>
> I've done some searching, and found out that I need a non-default
> version of gcc (10 or 11) with support for Modules.
>
> I've installed gcc-11 as indicated on the Wiki page
> (https://gcc.gnu.org/wiki/cxx-modules) and the example code there works
> fine.
>

I'll reply to your main question when I have more time, but for now I'll
just point out that the modules support has been merged to the development
trunk now (the 'master' branch in git). So you don't need to use the
cxx-modules branch.


>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-21 18:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21 12:03 Building Standard Library Header units Patrick Kox
2020-12-21 17:28 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).