100% found this document useful (6 votes)
57 views

PDF Beginning C++ Compilers: An Introductory Guide to Microsoft C/C++ and MinGW Compilers 1st Edition Berik I. Tuleuov download

Tuleuov

Uploaded by

huvindjuly
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (6 votes)
57 views

PDF Beginning C++ Compilers: An Introductory Guide to Microsoft C/C++ and MinGW Compilers 1st Edition Berik I. Tuleuov download

Tuleuov

Uploaded by

huvindjuly
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Download Full Version ebookmass - Visit ebookmass.

com

Beginning C++ Compilers: An Introductory Guide to


Microsoft C/C++ and MinGW Compilers 1st Edition
Berik I. Tuleuov

https://ebookmass.com/product/beginning-c-compilers-an-
introductory-guide-to-microsoft-c-c-and-mingw-compilers-1st-
edition-berik-i-tuleuov/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmass.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Beginning C++ Compilers: An Introductory Guide to


Microsoft C/C++ and MinGW Compilers 1st Edition Tuleuov

https://ebookmass.com/product/beginning-c-compilers-an-introductory-
guide-to-microsoft-c-c-and-mingw-compilers-1st-edition-tuleuov/

ebookmass.com

Critics, Compilers, and Commentators: An Introduction to


Roman Philology, 200 Bce-800 Ce James Zetzel

https://ebookmass.com/product/critics-compilers-and-commentators-an-
introduction-to-roman-philology-200-bce-800-ce-james-zetzel/

ebookmass.com

Beginning C: From Beginner to Pro 7th Edition Gonzalez-


Morris

https://ebookmass.com/product/beginning-c-from-beginner-to-pro-7th-
edition-gonzalez-morris/

ebookmass.com

Ortner's identification of pathological conditions in


human skeletal remains 3rd. Edition [Edited By] Jane E.
Buikstra
https://ebookmass.com/product/ortners-identification-of-pathological-
conditions-in-human-skeletal-remains-3rd-edition-edited-by-jane-e-
buikstra/
ebookmass.com
Theatre in Your Life 3rd Edition, (Ebook PDF)

https://ebookmass.com/product/theatre-in-your-life-3rd-edition-ebook-
pdf/

ebookmass.com

The Psychology of Evolving Technology: How Social Media,


Influencer Culture and New Technologies are Altering
Society 1st Edition Rhoda Okunev
https://ebookmass.com/product/the-psychology-of-evolving-technology-
how-social-media-influencer-culture-and-new-technologies-are-altering-
society-1st-edition-rhoda-okunev-2/
ebookmass.com

(eTextbook PDF) for Food Around the World: A Cultural


Perspective 4th Edition

https://ebookmass.com/product/etextbook-pdf-for-food-around-the-world-
a-cultural-perspective-4th-edition/

ebookmass.com

The First Order (The Chronicles of Sister June Book 1) Amy


Cross

https://ebookmass.com/product/the-first-order-the-chronicles-of-
sister-june-book-1-amy-cross/

ebookmass.com

Artistic and Cultural Dialogues in the Late Medieval


Mediterranean 1st ed. Edition María Marcos Cobaleda

https://ebookmass.com/product/artistic-and-cultural-dialogues-in-the-
late-medieval-mediterranean-1st-ed-edition-maria-marcos-cobaleda/

ebookmass.com
Introduction to law 7th Edition Edition University Of
South Alabama

https://ebookmass.com/product/introduction-to-law-7th-edition-edition-
university-of-south-alabama/

ebookmass.com
Beginning C++ Compilers
Berik I. Tuleuov • Ademi B. Ospanova

Beginning C++ Compilers


An Introductory Guide to Microsoft
C/C++ and MinGW Compilers
Berik I. Tuleuov Ademi B. Ospanova
Nur-Sultan, Akmolinskaia, Kazakhstan Nur-Sułtan, Kazakhstan

ISBN-13 (pbk): 978-1-4842-9562-5 ISBN-13 (electronic): 978-1-4842-9563-2


https://doi.org/10.1007/978-1-4842-9563-2

Copyright © 2024 by Berik I. Tuleuov and Ademi B. Ospanova


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of
the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology
now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol
with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only
in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject
to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for
any errors or omissions that may be made. The publisher makes no warranty, express or implied, with
respect to the material contained herein.

Managing Director, Apress Media LLC: Welmoed Spahr


Acquisitions Editor: Susan McDermott
Development Editor: James Markham
Coordinating Editor: Jessica Vakili

Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring
Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-
[email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and
the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM
Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected]; for reprint, paper-
back, or audio rights, please e-mail [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk
Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available
to readers on the Github repository: https://github.com/Apress/Beginning-CPP-Compilers. For more
detailed information, please visit https://www.apress.com/gp/services/source-code.

Paper in this product is recyclable


Berik dedicates the book to the memory of his
father, Iglik K. Tuleuov. He expresses
gratitude to his family for their endless
patience while working on this book,
colleagues and Apress editors for their
kindness.
Contents

1 Files and Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1


1.1 File Types and Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Executable and Batch Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 System Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Mounting Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.5 Virtual Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 Software Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1 Overview of Installation Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Installation Packages (msi) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3 Installing with Archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 Installing from Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.5 Portable Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.6 Best Software Installation Practices for Windows Systems . . . . . . . . 11
2.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3 Programming Languages and Software. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1 Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2 C/C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3 Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.4 Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.5 C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4 General Build Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.1 Unix Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.1.1 GNU Autotools (GNU Build System) . . . . . . . . . . . . . . . . . . . . . 24
4.2 Windows Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2.1 nmake Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2.2 Visual Studio .vcxproj and .sln Files . . . . . . . . . . . . . . . . . . . . . . 26
4.2.3 MSBuild Build System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.3 Cygwin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.4 Cross-Platform Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

vii
viii Contents

5 Some Useful Open Source Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35


5.1 Far Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5.1.1 Default Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.1.2 Easy Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.1.3 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.2 7z . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.2.1 Default Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.2.2 Easy Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.2.3 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.3 Notepad++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.3.1 Default Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.3.2 Easy Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.4 lessmsi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.4.1 Easy Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.4.2 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.5 WinCDEmu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.5.1 Easy Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.5.2 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6 Command-Line Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
6.1 Command Interpreter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
6.1.1 Launching and Executing Commands in the
Command Line (Terminal, Console) . . . . . . . . . . . . . . . . . . . . . . 53
6.1.2 Path Separator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
6.1.3 Windows Standard Command Line . . . . . . . . . . . . . . . . . . . . . . . . 55
6.2 Environment Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
6.2.1 Modification of the PATH System
Environment Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
6.3 Access Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
6.4 ConEmu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
6.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7 Integrated Development Environments and Editors . . . . . . . . . . . . . . . . . . . 63
7.1 Microsoft Visual Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.2 Qt Creator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.3 Code::Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
7.4 Geany . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
7.5 Kate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
7.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Contents ix

8 Minimal Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.1 MSYS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.2 Default Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
8.3 Easy Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8.4 Some Tips. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
8.5 MSYS2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
8.6 Default Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
8.7 Easy Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
8.8 CMake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
8.9 Default Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
8.10 Easy Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
8.11 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
9 Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
9.1 GCC/MinGW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
9.1.1 Default Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
9.1.2 Building from the Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
9.1.3 Easy Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
9.2 Microsoft C/C++ Optimizing Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
9.2.1 Default Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
9.2.2 Easy Installation (Without Visual Studio)
with EWDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
9.2.3 Using Microsoft C/C++ Compiler with EWDK . . . . . . . . . . 101
9.2.4 Microsoft C/C++ Compiler Options . . . . . . . . . . . . . . . . . . . . . . . 102
9.2.5 Using MSBuild with EWDK. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
9.3 Intel C/C++ Optimizing Compiler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
9.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
10 Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
10.1 Dynamic and Static Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
10.2 Building Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
10.3 Creating User Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
10.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
11 Using Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
11.1 Linking with Static Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
11.2 Linking with Dynamic Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
11.3 Using Libraries from Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
11.4 Universal CRT Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
11.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
12 GMP (GNU Multiprecision Library) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
12.1 Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
12.1.1 GNU MPFR Library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
12.2 Example: Computation of 10 000 000!. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
12.3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
x Contents

13 Crypto++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
13.1 Building with MinGW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
13.2 Building with Microsoft C/C++ Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . 152
13.3 Example: AES Implementation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
13.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
14 OpenSSL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
14.1 Building with MinGW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
14.2 Building with Microsoft C/C++ Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . 159
14.3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
15 Process Hacker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
15.1 Building with Microsoft C/C++ Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . 167
15.1.1 Building Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
15.1.2 Building Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
15.2 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

A Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
About the Authors

Berik I. Tuleuov is Senior Lecturer at L. N. Gumilyov Eurasian National Univer-


sity, Nur-Sultan, Kazakhstan. He’s a researcher and mathematician using computers
for scientific computations and designing algorithms. He runs a topic on The AIFC
Tech Hub (a meeting point for global startups, entrepreneurs, investors, industry’s
top experts and talent pool) about Microsoft C/C++ compilers. This forum has more
than two million registered participants. He regularly takes part in academic and
industry conferences, mainly on computer science topics. Interests include program-
ming languages, algorithms and data structures, concurrent (parallel) programming,
scientific programming, (La)TeX Typesetting System, and data visualization.

Ademi B. Ospanova is an Associate Professor in the Department of Information


Security at L. N. Gumilyev Eurasian National University. She is the author of many
courses in the field of IT technologies. She is developer of educational programmes
of all levels of the university on information security. In the educational process
and projects she uses her own software and libraries in C/C++, C#, Java, Prolog,
R, Python, Solidity, works in Mathematica, Maple, Sage packages. She also has her
own website, including hosting on her own server.
She manages grant and initiative research projects, and her Masters and PhD
students are winners of national scientific competitions.
She also gives courses and consultations on cryptography and programming to
specialists from various companies.

xi
About the Technical Reviewer

Sedat Akleylek received the B.Sc. degree in mathematics majored in computer


science from Ege University, Izmir, Turkey, in 2004, and the M.Sc. and Ph.D.
degrees in cryptography from Middle East Technical University, Ankara, Turkey, in
2008 and 2010, respectively. He was a Postdoctoral Researcher at the Cryptography
and Computer Algebra Group, TU Darmstadt, Germany, between 2014 and 2015.
He was an Associate Professor at the Department of Computer Engineering,
Ondokuz Mayıs University, Samsun, Turkey, between 2016 and 2022. He has been
Professor at the Department of Computer Engineering, Ondokuz Mayıs University,
Samsun, Turkey, in 2022. He has started to work at the Chair of Security and
Theoretical Computer Science, University of Tartu, Tartu, Estonia since 2022. His
research interests include the areas of post-quantum cryptography, algorithms and
complexity, architectures for computations in finite fields, applied cryptography for
cyber security, malware analysis, IoT security, and avionics cyber security. He is
a member of the Editorial Board of IEEE Access, Turkish Journal of Electrical
Engineering and Computer Sciences, Peerj Computer Science, and International
Journal of Information Security Science.

xiii
Acknowledgments

Ademi would like to dedicate the book to her fragile but strong mother who cares
for her entire family. She provides Ademi with warmth and the opportunity to do
her job.

xv
Introduction

Anyone who wants to start programming in the C/C++ languages needs two things
in general: a computer and two programs called a C/C++ language compiler and a
source code editor (generally speaking, the so-called debugger — a program that
helps find errors in the source code, but still it is not necessary). More, in principle,
nothing is needed.
If any text editor (for example, Notepad on Windows) is in principle suitable as
a source code editor, then the situation with compilers is not simple. On Windows,
they must be installed, and in the vast majority of cases, when it comes to installing
the C/C++ compiler, for some reason it means installing Microsoft Visual Studio,
which requires a lot of computer resources. Meanwhile, Microsoft Visual Studio is
not a compiler, but the so-called Integrated Development Environment (IDE), which
includes, among other components, also a C/C++ language compiler.
As far as we know, there are no books devoted to installing C/C++ compilers1 ,
it is implicitly assumed that the user has the compiler either already installed, or
its installation is standard and does not cause difficulties. However, there are many
pitfalls here, and we will try to briefly describe the motives that prompted us to write
our book.
Under Windows, usually installing a C/C++ compilers, especially Microsoft
ones, takes quite a lot of time, because it comes with Microsoft Visual Studio for
the vast majority of users. Installing Visual Studio requires usually about 40 GB of
disk space and big amount of RAM, so it is impossible to use weak hardware. So
we suggest an easy way to deploy Microsoft C/C++ compiler: no headache with
disk space and hardware resources lack. Additionally, our means saves big amount
of time since one can deploy software on removable devices, such as flash sticks,
and use it easily in a portable way. We achieve this by using Enterprise Windows
Driver Kit (EWDK), a single, large ISO file, which can be mounted as virtual
device and used directly without any installation. EWDK contains everything from
Visual Studio except IDE. EWDK also allows to use MASM64 (Microsoft Macro-
Assembly) and C# compilers. With the aid of MSBuild System one can compile
Visual Studio Projects (.vcxproj) and Solutions (.sln) even without Visual Studio!
Analogously, MinGW compilers can be deployed from 7z/zip archives, simply by

1 There are a lot of books on the C/C++ languages themselves.

xvii
xviii Introduction

unpacking into appropriate location. Briefly, both Microsoft C/C++ and MinGW
compilers can be used as portable software. Notice that such approach does not
require an administrative privileges at all.
It is Create Once, Use Many principle: one can deploy these compilers and
auxiliary software on removable device and use everywhere, or just copy it to hard
disk and use them from local disk. There is no need to re-install.
Also, users can use several versions of these compilers at the same time, they do
not interfere each other. Using MSYS (Minimal SYStem, a port of GNU Autotools)
allows to build under Windows many libraries originally designed for Unix-systems.
These things important because standard installation procedure doesn’t give such a
flexibility: very often various versions of installed software conflict with each other,
or it is impossible to install at all.
Our book is intended primarily for two categories of users:

• beginners to learn the C/C++ language, who don’t want to spend time on the
standard installation of MinGW and Microsoft C/C++ compilers, since in the
first case one has to make a difficult and non-obvious choice between different
builds of this compiler, and in the second — to solve computer resources lack
and installation problems;
• advanced users who, generally speaking, are not professional programmers, but
write small programs in standard C/C++, for, for example, scientific and technical
calculations.

Of course, the approach we propose can also be useful for professional program-
mers, as it saves a lot of time; in addition, the created toolkit can be used in the
future on a variety of computers without special preparation, since this toolkit is
portable.
We describe the MinGW and Microsoft C/C++ compilers, the clang compiler
is not covered (its popularity has not yet reached the level of first two). We set
as our main goal the description of compilers, and not various IDEs, so they are
practically not considered. Various advanced (lightweight) editors that have some
IDE functions are considered as code editors. We do not consider the currently
popular Visual Studio Code due to the fact that it is not lightweight (as we have
already noted, the IDE is an auxiliary tool for us; however, if the user has enough
memory installed on the computer, then nothing prevents using VS Code). We do not
consider code debuggers, an interested reader can later deal with this topic himself.
Also, we do not consider WSL (Windows Subsystem for Linux), since this
subsystem is designed to run Linux applications (and not all of them: for example,
restrictions apply to GUI applications) under Windows, and we are fighting to
build Open Source applications and libraries originally created for Unix systems
for Windows. WSL, although it provides less resource consumption compared to
virtualization, is still an additional layer that negatively affects the performance of
applications running under it. The programs and libraries compiled under Windows
using the tools we describe are native Windows applications and thus provide the
highest performance.
Introduction xix

For completeness of our research, we use a variety of versions of Windows, on


different computers and virtual machines (GNOME Boxes, VMware). The system
configurations on these platforms are different (different versions of Windows,
different amounts of disk space, etc.), which explains why throughout the book
the Programs, Soft, and User directories are located on various partitions of the
computer’s hard drive (and sometimes on removable devices). In part, we did this
intentionally, because we wanted, in accordance with the spirit of our book, in every
possible way to emphasize the flexibility and portability of the approach we use.
For the convenience of the reader, in the Appendixes we provide a number of
tables to facilitate the use of the Microsoft C/C++ compiler. These tables are taken
from the Microsoft website.
Files and Devices
1

General information on files and devices is given in this chapter. The concept of a
file is fundamental to computer science, so it’s important to be clear about it. The
issues of effective user interaction with the computer are also discussed.

1.1 File Types and Formats

In general, a file is a piece of information with an assigned name that is stored on


a computer media. The media could be a hard or SSD disk, compact or DVD disk,
magnetic tape, flash sticks and cards, etc.
Most computers have at least one disk drive, HDD or SSD, installed permanently.
Nowadays, laptops have no DVD drives at all. Almost all devices can be connected
to a computer via USB; in this case, a user can use removable media: flash sticks
and cards, external HDD/SSD disks, or CD/DVD media.
By type, computer files are divided into text and binary files. Text files contain
bytes that have a visual representation, as well as bytes that serve to control (line
feed, carriage return, tabulation). Simply put, the contents of a text file can be “read.”
Microsoft Word files, although containing text information for the most part, are
not text files, as they contain information about formatting, sizes and types of fonts
used, and other meta-information, as well as other data, such as pictures. Generally,
binary files can contain human-readable pieces too.
By format, files are divided into graphics, multimedia (video and audio),
executables (programs), objects, archives, CD/DVD images, etc. On Windows, file
formats are recognized by their so-called extension: three or more letters after the
last period in the file name. For example, Adobe Acrobat Portable Document Format
(PDF) files have the extension '.pdf', and Microsoft Office documents have
extensions '.docx', '.xlsx', etc. For many programs, file extensions are

© The Author(s), under exclusive license to APress Media, LLC, 1


part of Springer Nature 2024
B. I. Tuleuov, A. B. Ospanova, Beginning C++ Compilers,
https://doi.org/10.1007/978-1-4842-9563-2_1
2 1 Files and Devices

not mandatory: for example, text editors can open the text file named “Readme”;
however, some software require strong extensions for their files.
Most file formats are designed to be independent of processor platforms and
operating systems. This means, for example, that the same pdf document can be
opened on Windows, Linux, Mac OS, Android devices, and finally iOS. However,
this is not the case for binary executables, which we will discuss as follows.

Note All files consist of bytes, both text and binary.

1.2 Executable and Batch Files

Before moving on, we need to make some clarifications. Most computer users, are
dealing with a modern and convenient graphical shell that provides ease of work.
The graphical shell of Windows is Explorer. The shell is an intermediary between
the user and the operating system, allowing you to open files, run programs, etc. In
the graphical shell, the mouse plays an important role, with which you can click the
icons of programs and documents to launch and open them.

Note Mouse actions can be duplicated via the keyboard.

However, the graphical shell is not the only one—there is another one, which is
called the command line. In the command line, the main role is played by another
device—the keyboard. The command line is mainly used to run commands by
typing the name of the command in the prompt and pressing the key. The
command can be either a system command (e.g., set or echo) or an executable
program file, and you must specify the exact location (full path to this file) of this
file. If such a file is not found due to nonexistence or an incorrect full path to it, the
system will display a corresponding message:
E:\Test>mycommand
'mycommand' is not recognized as an internal or external command,
operable program or batch file.

E:\Test>

Commands can have parameters called options. Their number depends on the
purpose of the command. As a rule, commands have built-in help, which in
Windows is called like this:
E:\Test>echo /?
Displays messages, or turns command-echoing on or off.

ECHO [ON | OFF]


ECHO [message]
1.2 Executable and Batch Files 3

Type ECHO without parameters to display the current echo setting.

E:\Test>

Conventional notation [option] means that the 'option' parameter in


square brackets [ ] can be omitted (and the brackets are omitted), and the '|'
in ON | OFF means that one of the two options must be selected (sometimes,
it happens that options can be combined, or, conversely, some options may be
incompatible with some other options; such cases are specifically discussed in the
help of the command).
For open source utilities, help is usually called in the format
E:\Test>command --help

So how to find this command line? Very simple: Press the + keys
and type cmd (cmd.exe is also possible) and press the key. Windows
will bring up a command prompt window.

Note In earlier Windows versions, this file was called COMMAND.COM. In


modern Windows versions, this file is called CMD.EXE and is located in the
C:\Windows\System32 directory.

Although the command line looks inconvenient, it undoubtedly has advantages


over the graphical shell, especially when it comes to automating sequential actions,
that is, for programming a certain sequence of operations. An example from the
practice of one of the authors: It was required to extract all graphic files from a filled
CD while maintaining the directory structure; there were many nested directories on
the disk. In the graphical shell, this task is almost impossible to solve quickly, but
on the command line, this task is solved in a couple of minutes, using the xcopy
utility with the /s key (option).
Executable files contain program code that is executed by the central processor of
a computer. Windows executable file formats include (by file extension) '.exe',
'.com', '.dll', '.sys', '.ocx', etc.

• exe: The main format of Windows executable program files.


• com: This extension belonged a long time ago to 16-bit MS-DOS programs
that were small and could use a small amount of RAM. On purely 32-
bit and 64-bit operating systems, such programs cannot run (they can only
run in compatibility mode or in emulators). Currently, Microsoft has made
a change where the format of binary executable files is determined not by
the extension but by the content of the file, so that any '.exe' file can
be renamed to a '.com' file without breaking functionality. This change
was made for compatibility with older MS-DOS batch files that called older
utilities with '.com' extensions, the newer versions of which are already
larger than the limits of the old '.com' format. Here is a list of these util-
4 1 Files and Devices

ities: chcp.com, diskcomp.com, diskcopy.com, format.com,


mode.com, more.com, and tree.com.
• dll: Dynamic-link libraries; they can contain both reusable executable code and
data. The vast majority of Windows code reside in such libraries.
• sys: Windows device drivers; these files are binaries, and they are created by
compilers from their human-readable source code in high-level programming
languages such as C/C++ and Assembly (parts of drivers).

Windows '.exe' files have so-called “magic bytes”: their first two bytes are
always 'MZ'.
Batch files on Windows have extensions '.bat' and '.cmd'.
Executable files in '.exe' and '.com' formats as well as batch files
('.bat', '.cmd') can be directly launched by the user. This can be done both
in the graphical shell and on the command line. In the graphical shell, open the
Explorer window, find the file to be launched, and double-click it. For the second
method, launch the command prompt, type the full file name, and press the
key.
Notice that for binary executable files and batch files, when they are executed,
their extensions can be omitted on the command line. In this regard, an inter-
esting question arises: If the files test.bat, test.cmd, test.com, and
test.exe are in the same directory, then which one will be executed when the
test command is executed?
Answer: The order of execution is '.com', '.exe', '.bat', '.cmd';
hence, test.com will be executed. To execute any other of them, you need to
write its name in full with the extension, for example, test.exe. In general, the
execution priority is determined by the PATHEXT environment variable and can be
changed, which we will talk about later.
A batch file is a text file, each line of which consists of a single command that
can have parameters. Thus, a batch file can execute several commands sequentially
one after another, that is, by running one command, we actually execute a whole
series of commands! Therefore, such files are sometimes called script files.
It is important to note that binary executables are not only operating sys-
tem dependent but also processor architecture dependent: for example, Windows
'.exe' files do not run on Linux or Mac OS; moreover, '.exe' files created
for 64-bit Windows do not work in 32-bit Windows (the opposite is true: 32-bit
Windows '.exe' files work in 64-bit Windows in compatibility mode). Likewise,
Linux binaries don’t work on Windows.
Batch files are a bit more flexible in this regard: while Windows '.bat' and
'.cmd' files don’t work on Linux, you can create script files on Windows that are
cross-platform with some limitations. We will cover this in later chapters.

Note In Unix systems, every file can be made executable in terms of those systems.
1.4 Mounting Devices 5

1.3 System Commands

System commands are for executing common basic system commands. System
commands are divided into internal and external ones. Internal commands are
implemented in the CMD.EXE file; external commands are implemented as
separate utilities located in the C:\WINDOWS\System32 system directory. An
example of an external command is the abovementioned xcopy (xcopy.exe),
an advanced file and directory copying utility.
Help on these commands, as noted earlier, can be called with the /?.
We briefly describe here some useful commands:

cls clears the console window (clear screen).


set sets a value to an environment variable.
echo echoes its argument value.
cd changes the working directory (change directory).
dir types the content of the current directory.
path displays the value of the PATH environment variable.

echo %PATH% types the value of the PATH environment variable.

1.4 Mounting Devices

Sometimes, in Windows you have to change the letter of the CD/DVD drive or even
the hard disk partition. This can be done through the Computer Management applet,
which is invoked by right-clicking the Computer icon in the Desktop. Note
that this requires administrator rights.
Much more interesting and useful is the subst command, which does not
require administrator rights and allows you to mount a folder as a disk partition,
assigning a given letter to this disk:
E:\Test>subst /?
Associates a path with a drive letter.

SUBST [drive1: [drive2:]path]


SUBST drive1: /D

drive1: Specifies a virtual drive to which you want to


c→ assign a path.
[drive2:]path Specifies a physical drive and path you want to
c→ assign
to a virtual drive.
/D Deletes a substituted (virtual) drive.

Type SUBST with no parameters to display a list of current


c→ virtual drives.

E:\Test>
6 1 Files and Devices

For example, the command


E:\Test>subst X: E:\Test

will create disk X: in the system (if it, of course, did not exist) and mount all the
contents of the E:\Test directory on this disk. We will use this command later
when working with the Microsoft C/C++ compiler.

1.5 Virtual Devices

Some software is shipped in the ISO format. Examples are Linux distributions,
Microsoft Enterprise Windows Driver Kit, and others. As we know, the ISO file
is an image of CD/DVD media, and in the old days, the user had to burn this file to
a blank CD/DVD disk and insert the disk into the drive. In our days, it is much more
easier to handle such files— it suffices to use the so-called virtual devices. The user
just creates such a device and mounts the ISO file on the device.
We work with DVD virtual devices. Virtual devices are created programmati-
cally; no physical device is needed. Such devices can easily be created on Windows
7 with the aid of several software: DAEMON Tools Lite (www.daemon-tools.
cc/products/dtLite), Alcohol 120% Free Edition (http://trial.alcohol-soft.com/en/
downloadtrial.php, all Windows operating systems except 98/ME, for personal use
only), etc. These tools require installation and system reboot.
In our opinion, the best program of this kind is WinCDEmu, an open source
CD/DVD/BD emulator (https://wincdemu.sysprogs.org); this program has a
portable version (https://wincdemu.sysprogs.org/portable/). Portable single exe-
cutable file runs under all versions of Microsoft Windows (10/8.1/8/7/2008/Vista/
2003/XP), on both x86 and x64 platforms. No system reboot is needed.
WinCDEmu is

• Free for any kind of use.


• Lite, about 670 KB only.
• Easy to use, just run the downloaded portable exe.

Of course, WinCDEmu requires administrator privilege to create virtual devices


and mount ISO images.
On Windows 10 and up, no additional software of this kind is needed at all. Just
right-click the ISO image on the Explorer window and select the “Mount” menu
item. The system itself will create the device, assign it a letter, and mount the image
there—no matter if the user has administrator privilege or not (no matter if the user
has administrative rights or not).
1.6 Conclusion 7

1.6 Conclusion

In this chapter, we have tried to clearly describe the concept of a file, which is
fundamental for computer sciences, to classify them according to various features
and ways of using them. It is also important to understand what executable and batch
files are and the order in which executable files are launched.
Since we actively use virtual disks in the book, we have given a description of
programs and commands for creating them.
Software Installation
2

2.1 Overview of Installation Methods

Every software on the computer should be installed in a certain way, in a certain


location on the user’s hard disk. The vast majority of software under Windows is
installed in the 'C:\Program Files' ('C:\Program Files (x86)'
for 32-bit programs) folder.
Usually, every software resides in its own, so-called home folder. The home
folder may contain a folder named bin, which stands for binary, containing the
main executable file of the software. When you click this executable in the Explorer
window or click this program icon in the start menu, the operating system launches
it.
There is one more way to launch a program: from the command line. This way
is the most flexible (but not convenient for simple users) one, and further we will
consider it in detail. For Windows, the most popular (and widely used) way is its
standard one: users should just click the installation file to get started.
In the old days, an installation package contained archived components of
software and driver files designed for the installation of this software on a user’s
computer. An installation package includes also a file called Setup or something
like which launches installation process; this file might be of exe or bat type.
The Setup program does the following:

• Extracts the components of the software being installed form archive into a
temporary folder (usually TEMP)
• Copies extracted files into the appropriate location in the user’s computer
• Modifies the Windows system registry for some parameters
• Carries out system-wide and user-level changes for some parameters such as
PATH
• Creates system menu items and icons and desktop shortcuts for quick launch

© The Author(s), under exclusive license to APress Media, LLC, 9


part of Springer Nature 2024
B. I. Tuleuov, A. B. Ospanova, Beginning C++ Compilers,
https://doi.org/10.1007/978-1-4842-9563-2_2
10 2 Software Installation

Of course, not every Setup program does have to carry out every step of this
scenario.
Sometimes, on updating, some software requires removing (uninstalling) the old
version in order to proceed. Uninstalling software usually is quite straightforward
but sometimes may cause problems, especially in the case of big packages such as
Visual Studio. Notice that very often some registry items related to software being
uninstalled stay undeleted and may cause errors on reinstalling.

Note It is not a good practice to add the path to the executable file of the software
being installed into the environment variable PATH.

2.2 Installation Packages (msi)

In recent years, an installation package consists of a single file of exe or msi


type. An exe file is a self-extracting archive, and msi is an archive which can be
handled by Windows installation service.
The advantage of this installation way is that the user is supposed to make a
minimal effort on installation: just click the file to start the installation process.

Note This way requires administrative privileges in most circumstances. Simple


users cannot install such kind of software.

2.3 Installing with Archives

The most recent trends should be pointed out about the subject: more and more
software packages are distributed not only in the form of msi but also zip/7z
archives. In our opinion, this method is one of the most flexible and has the following
advantages:

• No (traditional) installation is needed.


• Does not require administrative privileges.
• The Windows system registry is not affected, so several versions of the same
software can be used simultaneously.
• Can easily be removed (uninstalled)—the user just deletes the program’s folder.
• Can easily be relocated—the user just moves the program to another place and
makes minimal change in one driver file.
• Can easily be cloned to another place analogous to the previous item.
• Can easily work from removable devices.

This method is especially suitable for compilers since these kinds of software are
designed to work in the command line. Recall that compilers themselves have no
visual interface; they always work in the command line.
2.6 Best Software Installation Practices for Windows Systems 11

The most popular GCC C/C++ compiler also works under Windows operating
systems, and its port to these systems is called MinGW (Minimalist GNU for
Windows). MinGW can be downloaded as (in the form of) both source code and
zip/7z (sometimes, as self-extracting exe) archive packages.

Warning It is a common mistake to consider Visual Studio as a compiler. Visual


Studio is a so-called IDE (integrated development environment) which includes
compilers, editors, debuggers and other related stuff.

2.4 Installing from Sources

Another installation way is installing from the source code of a software or library.
This way is the most flexible but complicated one.
The vast majority of Linux software are distributed with source code, together
with prebuilt binaries.
However, many libraries are provided only in source code (binaries may cause
compatibility issues on Linux systems), because usually it is easy to build from
sources. These libraries could also be built under Windows, with some additional
efforts.
Source code is written in high-level programming languages and should be
compiled using the compilers of these languages, so users have to have the
corresponding compilers installed in their system. We will discuss these topics
further.

2.5 Portable Installation

Software packages distributed in the form of zip/7z archives can be burned into a
CD/DVD disk after extraction from the archive so that they can work directly from
CD/DVD.
It is even easier to write such programs to flash media and run from there. These
are examples of the so-called portable installation.

2.6 Best Software Installation Practices for Windows Systems

Now let’s talk about one installation method. This way looks somewhat complicated
for normal users since it takes some effort; however, it is done once, and the results
can be used many times afterward. Of course, these are only recommendations, not
strong rules, but they save time and effort in the future.
Our first recommendation is not to install software in system default locations,
such as C:\Program Files, except some software which require reinstalla-
tion after Windows reinstallation, such as Microsoft Office, Microsoft Visual Studio,
Adobe software, etc.
12 2 Software Installation

Here are the reasons for doing so:

• Such kind of software requires fresh installation after Windows crash and
reinstallation.
• It cannot be installed without system administrator privileges.
• It cannot be copied or moved to another place without disruption.
• It cannot be copied or moved to removable media without disruption.

Moreover, we strongly do not recommend installing the software in question on


drive C: disk at all. The user had better divide their HDD, creating a new partition,
and put their software and data there. In modern Windows versions, it is done so
easily—it takes just five minutes to create a new disk partition! In Windows 10,
right-click My Computer, select Manage, and then choose Disk Management from
the window that appears. Select the C: disk in the lower part and right-click it, then
select Shrink (Figure 2-1).
Here are the reasons for doing so:

• System crash does not affect user software and data.


• Software is ready for use after Windows recovery.
• No system administrator privileges are needed.
• Software can be copied or moved to any place.
• Software can be placed to removable media and launched in a portable way in
another computer.
• Several versions of the same software can be used simultaneously.

Figure 2-1 Creating a new partition


2.6 Best Software Installation Practices for Windows Systems 13

It is easy to launch the terminal window from any folder in the Linux graphical
interface without the need to explore using the cd command. For a long time,
this was not possible in Windows systems, but in the seventh version, such an
opportunity appeared. The user just has to right-click a folder icon while holding
the button (Figure 2-1).
However, many users are missing the ''Open command window here'' con-
text menu item in the Explorer window in later Windows versions because Microsoft
replaced it with a PowerShell launching item. PowerShell is too complicated for our
purposes for many reasons; we will not discuss it here.
We strongly advise to do as follows. On the second disk partition, say D:,
create the following folders: Programs, Soft, and User. These folders are to hold
programs, software archives downloaded, and user data, respectively. Why do we
store downloaded software in a place other than the default Downloads folder? The
answer is this: usually, the Downloads folder is cluttered with a bunch of garbage,
and it can be difficult to quickly find something there. In addition, in case of damage
to the C: drive or reinstalling Windows, as we said earlier, this data will remain intact
and can be reused. We will consider fine-tuning issues in the following chapters.
Sometimes, it is useful to change the drive letter assigned to a partition or
CD/DVD device. How to do this using the same Computer Management snap-in
is shown in Figure 2-2.

Figure 2-2 Changing the DVD letter


14 2 Software Installation

Let’s describe in a generalized way our proposed method of installing some


program under a conditional name, say, SomeUtility-vX.Y.Z.7z,
where X.Y.Z means the version number of the program. Such pro-
grams, distributed as archives, have a bin subdirectory inside the archive,
where the program’s executable file (exe file) is located, as well as
the dll dynamic libraries necessary for its operation (sometimes such
libraries are not available). We must unpack the program archive into
the Programs\SomeUtility-X.Y.Z directory. For the program to
work correctly, the system needs to be told where the program’s executable
file is located, as well as the dynamic libraries necessary for its work—this
can be done by adding the Programs\SomeUtility-X.Y.Z\bin
directory to the PATH environment variable. To do this, we will create a batch
file SomeUtility-X.Y.Z.bat:
@echo off
set PATH=%~d0\Programs\SomeUtility-X.Y.Z\bin;%PATH%
and place it in the Programs\bin directory, then add this directory to the
system (if you have administrator access) or user PATH environment variable.
How to do this is described in Section 6.2.1, page 58.
To use, we just invoke the command SomeUtility-X.Y.Z[.bat]
from the command line. Of course, for convenience, you can name your
batch file shorter, for example, suXYZ.bat, and then it can be invoked
as suXYZ.

We demonstrate our approach with the help of a Figure 2-3.

2.7 Conclusion

In this chapter, we have given an overview of the methods for installing software
on the Windows operating system. We looked at four ways to install software and
considered the advantages and disadvantages of each of them. At the end of the
chapter, our recommendations were given with the justification of our proposed
method of installing the software.
In view of their importance, we repeat our recommendations here with somewhat
more detailed justifications:

1. It is undesirable to have only one partition (disk) C: on your hard drive. When
purchasing a computer, you can ask to share your disk. This operation is not
difficult; you can do it yourself, with some experience, but it is better to ask a
guru you know. In any case, it is better to do this when your disk is still slightly
full, in which case the risks are minimal, and the process itself will take a little
time.
2.7 Conclusion 15

Figure 2-3 Disk D directory tree


16 2 Software Installation

For the C: drive, in which the Windows system itself is located, it is enough
to allocate, say, 100 GB of space; the freed space can be allotted to the D: drive,
on which it is advisable to store data. The meaning of these actions is that if the
operating system breaks down (which happens quite often for various reasons:
viruses, illiterate user actions, etc.), your data will most likely remain intact and
will not be affected after the next reinstallation of Windows (recall that often,
when installing Windows, users completely format the C: drive, hoping to get rid
of viruses in this way).
2. Do not store data on the desktop! Do not store them in the so-called standard
folders like My Documents either—these folders are located by default in the
system partition (drive C:), and, if you are not a guru, then with such a breakdown
of Windows, when only the command line is available to you, you will not be able
to copy them. The data in such folders can be encrypted for security purposes,
which also adds to the problems in their recovery.
These problems can be avoided by storing data in the D: partition. Even if
you format the C: drive by mistake when reinstalling the system, your data will
remain intact. As for security, the users themselves can encrypt their data on the
D: drive.
Of course, the desktop is the very first place that comes to hand when you
need to quickly save something; however, as we have already shown, this is not
the best place. On the desktop, you only need to create shortcuts to folders with
data—the loss of shortcuts is not critical compared to the loss of data.
3. When creating directories (folders), avoid using national (and other non-English)
letters, as well as spaces! Until now, there are programs that incorrectly process
such paths. At best, such programs will crash, and at worst, they will behave
unpredictably, and the user risks wasting time looking for an unknown error.
Spaces in directory names are also undesirable because when working in
command-line mode, such paths have to be enclosed in (usually) double quotes,
which is very inconvenient. For this reason, do not install, for example, compilers
in the Program Files directory.
4. You should prefer such programs that do not require standard installation. The
reason is that they do not require installation, which saves time, and when
reinstalling the system, they do not need to be reinstalled. It should be noted that
such programs, as a rule, do not use the Windows system registry. Examples of
such programs are the Far Manager file and archive manager (http://farmanager.
com/), the popular VLC media player (www.videolan.org/vlc/), advanced text
editor Notepad++ (http://notepad-plus-plus.org/), various builds of the MinGW
compiler (porting the GCC compiler to Windows), and there are more and more
of them. Such programs are distributed in the form of an archive (zip, 7z, and
other formats); to install them, it is enough to unpack them into some directory.
There are several ways to customize the application, which are described in the
next sections

For programs that do not require installation, it is better to allocate a separate


directory, for example, D:\Programs.
Programming Languages and Software
3

Currently, there are a large, if not huge, number of high-level languages; however,
when it comes to scientific and engineering computing, the choice narrows sharply,
literally to three (and in fact, to two) languages: C/C++ and good old Fortran.

3.1 Programming Languages

3.2 C/C++

The C language was created in the early 1970s by Dennis Ritchie of AT&T Bell
Laboratories (Bell Labs) to write the Unix operating system. The C language has
had a huge impact on the computer industry: operating systems are written almost
entirely in this language, and many popular modern languages (C++, C#, Java,
JavaScript, and Objective-C) have actually borrowed its syntax.
Due to the presence of pointers in C, it is possible to write almost assembler
programs that are characterized by high execution speed. And at the same time, C is
much easier to write for most programmers than Fortran. Therefore, many modern
libraries for scientific and engineering calculations are already written in C, not in
Fortran.
The C language is standardized. In 1989, ANSI X3.159-1989 (ANSI C or C89)
was adopted. In 1990, the ANSI C standard was adopted, with a few modifications,
by the International Organization for Standardization (ISO) as ISO/IEC 9899:1990.
In 1999, the ISO 9899:1999 (C99) standard was adopted. In March 2000, it was
adopted and adapted by ANSI. On December 8, 2011, the new ISO/IEC 9899:2011
(C11) standard was published.
The canonical reference for the C language is the book by Brian Kernighan and
Dennis Ritchie The C Programming Language often cited as KR or K&R, originally
published in 1978 (by the way, it was in this book that the authors introduced the

© The Author(s), under exclusive license to APress Media, LLC, 17


part of Springer Nature 2024
B. I. Tuleuov, A. B. Ospanova, Beginning C++ Compilers,
https://doi.org/10.1007/978-1-4842-9563-2_3
18 3 Programming Languages and Software

tradition of writing as the first program in the target language a program that prints
the greeting “hello, world”, since then it has become an unwritten rule). The current
state of the language can be read in Ben Clemens’ book 21st Century C.
The C++ language was also created at AT&T Bell Laboratories, but by another
person—Bjarne Stroustrup, a Dane living and working in the United States. Its
original goal was to expand the C language by adding elements of object-oriented
programming there; for this reason, at first the new language was called C with
classes. In 1983, the language was renamed to C++ because it had grown from being
a simple extension of the C language—there were so many additions. But despite
all the changes, C++ remains compatible with the C language, with rare exceptions.
An important part of the C/C++ languages is the so-called standard library: for
example, C does not have a formatted output operator like write/writeln in
Pascal, but the printf function, which is found in the standard library. To use this
feature, you must include the corresponding header file. Similarly, the C++ standard
library includes not just input/output (I/O) classes and implementation functions
and classes of this kind (e.g., complex for working with complex numbers) but
also entire sublibraries of the STL type (STL, Standard Template Library, written
by Alexander Stepanov and has long become part of the language), including
sorting and searching algorithms. The language also provides work with strings and
regular expressions, with various data structures (dynamic arrays, linked lists, binary
trees, hash tables). In recent language implementations, classes for developing
multithreaded and parallel programs have been added to the standard library, support
for internationalization and classes for working with numbers (random numbers and
distributions, numeric functions) have been improved. In addition, there are a huge
number of utilities (e.g., clocks and timers).
Since 2012, C++ standards have been adopted on a three-year cycle. In 2020, the
ISO/IEC 14882:2020 standard, often referred to as C++20, was adopted, which is
the current one today. The C++23 standard is planned for this year (2023).
We recommend that you often look at https://cppreference.com, where you
can get not only comprehensive reference information but also code examples
illustrating the intricacies of using the element of the C++ language being studied.
We also recommend a number of books ([4] to [10]) on scientific programming that
use C and C++ to varying degrees.
The source code files of C programs have the .c extension, and the header files
have the .h extension. C++ files use .cpp and .cxx extensions, while header
files can have .hpp and .hxx extensions.

3.3 Fortran

Despite the seemingly solid old age (almost 60 years), the Fortran language is
not going to give up its positions at all: in 2010, the next Fortran 2008 language
standard was adopted, and work is actively underway on the next Fortran 2015
standard (a standard for programming languages alike, and for other areas, it is
very important—e.g., the Delphi language was not standardized, and its Pascal
3.4 Assembly 19

prototype has already three standards and even more implementations that are
incompatible between themselves; as a result, these languages are effectively dead).
The Fortran language (FORmula TRANslator) was developed at IBM in 1957 by
a group of specialists led by John Backus and was de facto the first high-level
algorithmic language (the first was the Plankalkul language, in German—calculus
plan, designed by the German engineer Konrad Zuse in 1945, but he did not have the
opportunity to implement his language; implementation completed only in 2000).
The main advantage of Fortran is the presence in the source code of care-
fully written, debugged, very efficient, and well-documented software packages
(libraries) for scientific and engineering calculations. A number of such libraries are
available commercially: NAG Numerical Library from The Numerical Algorithms
Group (NAG), IMSL Numerical Libraries (Rogue Wave Software), etc. These
libraries enjoy well-deserved prestige among specialists.
Another advantage of the Fortran language is the high speed of code execution.
In this parameter, Fortran is close to assembly language. Fortran is perhaps the
most standardized language: FORTRAN IV (FORTRAN 66, 1972), FORTRAN
77 (1980), Fortran 90 (1991), Fortran 95 (1997), Fortran 2003 (ISO/IEC 1539-
1:2004), Fortran 2008 (ISO/IEC 1539-1:2010). The language is actively developing;
for example, the Fortran 90 standard introduced a free format for writing code, as
well as elements of object-oriented programming, which were further developed in
the Fortran 2003 standard (in fact, the list of innovations is huge: actually, this is
like a new language; for those who studied the classical version of the language, the
amount of changes can be assessed only by studying the new standard). In the latest
versions of the standards, a lot of attention is paid to parallel computing.

3.4 Assembly

Assembly language allows you to create the shortest and fastest programs, but the
price of this is the large size of the source code. From this point of view, the use of
this language is inefficient, since it requires a lot of labor. However, this language has
its own niche—where you need a small code size and high speed of its execution.
Therefore, assembly code is used when writing drivers, as well as when writing
some components of the operating system that closely interacts with the hardware,
the so-called HAL (hardware abstraction layer).
One of the most common assemblers for Windows is the Microsoft Macro
Assembler (MASM), which is part of the Microsoft C/C++ compiler. It must be
emphasized that MASM is not supplied separately. We will briefly consider working
with it in subsequent chapters.
Assembly source code files have the extension .asm.
20 3 Programming Languages and Software

3.5 C#

The C# object-oriented language was developed by Microsoft and is intended


primarily for developing business applications. C# source code files have the
extension .cs.
This language has a number of advantages that distinguish it from modern
high-level languages; however, in our opinion, the presence of a couple of other
shortcomings makes it completely unsuitable for use in the field of scientific and
engineering calculations:

• C# is a platform-specific language, that is, only Windows applications can be


written in it. Attempts were made to port the .NET Framework runtime to Linux
(the Mono project), but this project did not gain much popularity for various
reasons.
• Applications written in C# are actually executed on a virtual machine—for this
reason, they are inferior in execution speed to C/C++ applications.
• Poor implementation of real types can lead to cumulative rounding errors!
Because of its importance, we will address this issue in more detail.

Here are some extremely interesting quotes from Joseph Albahari and Ben
Albahari’s book C# 5.0 in a Nutshell, Fifth Edition [3]. They concern the use of
the C# language in calculations. First, let’s clarify some definitions of the basic
types used in calculations. These are quotes from [3, page 24]:

Of the real number types, float and double are called floating-point types and are
typically used for scientific calculations. The decimal type is typically used for financial
calculations, where base-10–accurate arithmetic and high precision are required.

and [3, page 29]:

double is useful for scientific computations (such as computing spatial coordinates).


decimal is useful for financial computations and values that are “man-made” rather than
the result of real-world measurements.

Finally, we will quote in full from the short subsection Real Number Rounding
Errors [3, page 30]:

Real Number Rounding Errors


float and double internally represent numbers in base 2. For this reason, only numbers
expressible in base 2 are represented precisely. Practically, this means most literals with a
fractional component (which are in base 10) will not be represented precisely. For example:
float tenth = 0.1f; // Not quite 0.1
float one = 1f;
Console.WriteLine (one - tenth * 10f); // -1.490116E-08
This is why float and double are bad for financial calculations. In contrast,
decimal works in base 10 and so can precisely represent numbers expressible in base 10
3.5 C# 21

Figure 3-1 C# program

(as well as its factors, base 2 and base 5). Since real literals are in base 10, decimal can
precisely represent numbers such as 0.1. However, neither double nor decimal can
precisely represent a fractional number whose base 10 representation is recurring:
decimal m = 1M / 6M; // 0.1666666666666666666666666667M
double d = 1.0 / 6.0; // 0.16666666666666666
This leads to accumulated rounding errors:
decimal notQuiteWholeM = m+m+m+m+m+m; //
→ 1.0000000000000000000000000002M
double notQuiteWholeD = d+d+d+d+d+d; // 0.99999999999999989
which breaks equality and comparison operations:
Console.WriteLine (notQuiteWholeM == 1M); // False
Console.WriteLine (notQuiteWholeD < 1.0); // True

As an illustration, we give the texts of the simplest programs in C#1 and C++,
CSharp.cs and CPP.cpp, which implement a simple algorithm: the difference

1.0 − 0.1 ∗ 10
.

is calculated and then the result is displayed on the screen (Figures 3-1 and 3-2).
Note that the rather strange result of this C# program was tested in Windows
7, for the .NET Framework versions 2.0, 3.5 and 4.0. There is no such error in
Windows 10.

1 In order to compile a program in C#, it is not necessary to install Microsoft


Visual Studio; almost every Windows includes the .NET Framework, which
contains the C# language compiler. To build, you need to run the command
C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe CSharp.cs
22 3 Programming Languages and Software

Figure 3-2 C++ program

3.6 Conclusion

In this chapter, we have given a brief overview of the C/C++ and Fortran languages
and also provided important information about the C# language regarding compu-
tational aspects.
We also mentioned assembly language in the Microsoft implementation—
Microsoft Macro Assembler (MASM).
General Build Information
4

This chapter describes the process of building software on Unix-like and Windows
systems. A way to port the build process on Unix systems to the Windows platform
is given. New build tools in Windows are also given.

4.1 Unix Systems

The traditional tool for building programs and libraries in the world of Unix-like
systems is the famous make utility. Depending on what the utility is “ordered” to
do, it can do many things: compile files, create object files from them, build a library
from them, or, by linking them with runtime libraries, create an executable file and
place them in the specified directories in the system.
For all these purposes, the make utility calls the appropriate programs: the
compiler is called to compile, the archiver is called to create archived libraries, and
the linker is called for linking. make reads all these instructions from a special file
called Makefile.
Makefile is a text file of a special format; for simple projects, it can be created
manually; for large projects, there are automated tools creating such files.

Note The Makefile must reside in the root directory of the project.

Generally, Makefile contains a set of rules; a rule looks like this:


<targets ...>: <prerequisites ...>
recipe
...
...

© The Author(s), under exclusive license to APress Media, LLC, 23


part of Springer Nature 2024
B. I. Tuleuov, A. B. Ospanova, Beginning C++ Compilers,
https://doi.org/10.1007/978-1-4842-9563-2_4
24 4 General Build Information

Sometimes, another terminology is used for the rules:


<targets ...>: <dependencies ...>
command
...
...

make is guided by the rule in order to build the target file from the source files of
the project. A target is usually the name of executable or object files; it can also be
the name of an action to carry out. Examples of the latter are 'all', 'clean',
'install', and 'uninstall'; they are called 'Phony Targets' and
are marked by .PHONY in Makefile. Usual targets may depend on several files.

Note Failure to follow the Makefile format (often incorrect indentation at the
beginning of a line in the description of targets) leads to an error in the make utility.

Many parameters contained in the Makefile require clarification when trying


to build on a specific computer. For example, the system may not have installed (or
the wrong version) a required library, a compiler higher than a certain version may
be required, etc. To check all build options, a redistributable program or library
includes a special script called Configure. This script is usually written in
bash, but other languages can also be used, such as Perl.
As a result of the successful operation of the Configure script, a
Makefile is generated that is intended specifically for this computer.
Although some programs and libraries are also supplied in compiled (binary)
form, sometimes it is better to recompile them for a particular machine. The thing
is that the Configure script allows you to take into account, for example, the
parameters of the central processor and, in the case of a latest generation processor,
activates its capabilities.
This note is especially relevant to the GMP library, which is designed to work
with very large numbers.

4.1.1 GNU Autotools (GNU Build System)

The basic sequence of commands for building programs and libraries with some
variations comes down to the following:
$ ./Configure
$ make
# make install
4.2 Windows Systems 25

For some libraries (e.g., for GMP), the stage of checking the built result is desirable,
which is made by the command
$ make check

This step may take a significant amount of time.


Once the project is built, one can delete the object files as they are no longer
needed. For large projects with hundreds of files, this frees up a lot of disk space.
It may also be required when rebuilding the project after some changes in the
source texts of some files. This can be done with the command
$ make clean

There is also a command for uninstalling the software already installed:


$ make uninstall

4.2 Windows Systems


4.2.1 nmake Utility
The nmake utility supplied with the Microsoft C/C++ compiler is an analog of the
make utility and of course is not compatible with it. We give its parameters:
D:\Users\John>nmake /?

Microsoft (R) Program Maintenance Utility Version 14.31.31107.0


Copyright (C) Microsoft Corporation. All rights reserved.

Usage: NMAKE @commandfile


NMAKE [options] [/f makefile] [/x stderrfile] [macrodefs]
→ [targets]

Options:

/A Build all evaluated targets


/B Build if time stamps are equal
/C Suppress output messages
/D Display build information
/E Override env-var macros
/ERRORREPORT:{NONE|PROMPT|QUEUE|SEND} Report errors to Microsoft
/G Display !include filenames
/HELP Display brief usage message
/I Ignore exit codes from commands
/K Build unrelated targets on error
/N Display commands but do not execute
/NOLOGO Suppress copyright message
/P Display NMAKE information
/Q Check time stamps but do not build
/R Ignore predefined rules/macros
/S Suppress executed-commands display
/T Change time stamps but do not build
26 4 General Build Information

/U Dump inline files


/Y Disable batch-mode
/? Display brief usage message

D:\Users\John>

4.2.2 Visual Studio .vcxproj and .sln Files

When developing modern software, especially large software, the so-called inte-
grated development environments (IDEs) are used, which include not only high-
level language compilers but also debuggers to facilitate finding errors in programs
and optimizing their work, as well as advanced source code editors with syntax
highlighting and auto-completion functions and an advanced hint system, a system
for working with source code repositories and version control, a designer for
designing a graphical interface. Some environments contain database tools.
Of course, the source code of such applications consists of many files, and they
are usually combined into so-called Projects. The source code of such Projects
consists not only of files in some high-level programming language but also of
resource files (icons, images, audio and video, etc.) and settings files—up to the
cursor position in a specific file opened in the source code editor. Projects are created
in the IDE (of course, very simple Projects can be created by hand, following the
appropriate file formats, but this is usually not necessary), and each IDE has its own
format. Typically, IDE project files are XML files (text files with Unicode support).
Microsoft Visual Studio project files have the .vcxproj extension (for older
versions of Visual Studio, .vcproj). Visual Studio projects can be grouped into
so-called Solutions, which consist of multiple .vcxproj projects. It is interesting
to note that Solutions can combine projects written in different programming
languages. Solutions files have the extension .sln.
To build Visual Studio projects and solutions, MSBuild is a utility that is tightly
integrated into Visual Studio and is currently its native build system. However, we
note that it is not necessary to use MSBuild from the Visual Studio environment to
build projects and solutions—MSBuild can be run from the command line too.
Undoubtedly, projects make life easier when developing complex programs,
especially those with a visual interface. However, in practice, especially in academic
and scientific environments, you have to write programs that consist of a single
file (or a small number of files), and creating a project for such programs does not
make much sense. It is also important to emphasize that projects are generally not
cross-platform—they cannot be ported to another platform or operating system. For
researchers (and not only for them), this situation is not acceptable: for example,
having written an implementation of some algorithm in the standard C++ language,
the author wants to test the program on different platforms and operating systems.
For the preceding reasons, the ability of development environments to compile
individual files is important. As far as we know, in recent years, the developers of
Microsoft Visual Studio have also paid attention to this.
Random documents with unrelated
content Scribd suggests to you:
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project
Gutenberg™ works in compliance with the terms of this
agreement for keeping the Project Gutenberg™ name
associated with the work. You can easily comply with the terms
of this agreement by keeping this work in the same format with
its attached full Project Gutenberg™ License when you share it
without charge with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it
away or re-use it under the terms of the Project Gutenberg
License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country where
you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of the
copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.
1.E.5. Do not copy, display, perform, distribute or redistribute
this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must, at
no additional cost, fee or expense to the user, provide a copy, a
means of exporting a copy, or a means of obtaining a copy upon
request, of the work in its original “Plain Vanilla ASCII” or other
form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite
these efforts, Project Gutenberg™ electronic works, and the
medium on which they may be stored, may contain “Defects,”
such as, but not limited to, incomplete, inaccurate or corrupt
data, transcription errors, a copyright or other intellectual
property infringement, a defective or damaged disk or other
medium, a computer virus, or computer codes that damage or
cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES -


Except for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU
AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE,
STRICT LIABILITY, BREACH OF WARRANTY OR BREACH
OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE
TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER
THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR
ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE
OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF
THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If


you discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person or
entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR
ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you do
or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status by
the Internal Revenue Service. The Foundation’s EIN or federal
tax identification number is 64-6221541. Contributions to the
Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or
determine the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookmass.com

You might also like