Skip to content

Commit 96ca86a

Browse files
committed
Updated compilation instructions
1 parent d8003b9 commit 96ca86a

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed

README.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,52 @@
11
# learnmoderncpp-tutorial
22

3-
Complete, working programs from the C++ tutorial hosted at https://learnmoderncpp.com/course-details/
3+
Complete, working programs from the C++ tutorial hosted at:
4+
5+
https://learnmoderncpp.com/course-details/
46

57
## Usage
68

7-
The "headers" directory contains C++ programs with legacy header `#includes`,
8-
whilst the "modules" directory contains the same programs but using the `import` keyword instead.
9+
The "headers" subdirectory contains C++ programs with legacy header `#includes`, whilst the "modules" subdirectory contains the same programs but using the `import` keyword instead. See https://learnmoderncpp.com/2020/09/05/where-are-c-modules/ for more details about C++ compilers which have support for modules.
10+
11+
## Compiling under Windows
912

1013
All programs compile successfully under Windows with Visual Studio 2019 (v16.8 or later).
1114

1215
The supplied batch scripts `build-vs2019-headers.bat` and
13-
`build-vs2019-modules.bat` can be used to compile all of the programs within a Visual Studio command prompt terminal; simply run:
14-
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
15-
or similar in a command window, or create a desktop link.
16+
`build-vs2019-modules.bat` can be used to compile all of the programs within a Visual Studio command prompt, simply run:
17+
18+
```C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat```
19+
20+
or similar in a command window, or create a desktop link, and then run either of the build scripts.
21+
22+
Alternatively, to compile individual programs from within a Visual Studio command prompt run either (modules):
23+
24+
```
25+
cl /EHsc /std:c++latest /experimental:moodule /MD 00-example.cpp
26+
```
1627

17-
To compile individual programs under Linux, use:
28+
or (headers):
1829

1930
```
20-
g++ -std=c++20 -o prog prog.cpp # (for the headers versions)
31+
cl /EHsc /std:c++latest 00-example.cpp
2132
```
2233

23-
or
34+
substituting the correct file for `00-example.cpp` in either case.
35+
36+
## Compiling under Linux
37+
38+
To compile individual programs in the "headers" subdirectory under Linux, use:
39+
2440
```
25-
clang++ -std=c++20 -o prog prog.cpp # (again for the headers versions)
41+
g++ -std=c++20 -o 00-example 00-example.cpp
2642
```
2743

28-
Alternatively, run the supplied shell scripts which are supplied in both the "headers" and "modules" subdirectories.
44+
or:
45+
46+
```
47+
clang++ -std=c++20 -o 00-example 00-example.cpp
48+
```
2949

30-
**Contact:** cpptutor@outlook.com
50+
substituting both occurrencies of `00-example` with the correct file name.
3151

52+
Alternatively, run one of the supplied shell scripts `build-gcc-headers.sh` or `build-clang-headers.sh` which are supplied in the "headers" subdirectory, or `build-clang-modules.sh` found in the "modules" subdirectory. (The last of these needs to change `import std.core;` to `import std;` for each source file before compilation, using the `sed` utility.)

0 commit comments

Comments
 (0)