SlideShare a Scribd company logo
Download the full version and explore a variety of ebooks
or textbooks at https://ebookmass.com
Beginning C++ Compilers: An Introductory Guide to
Microsoft C/C++ and MinGW Compilers 1st Edition
Tuleuov
_____ Tap the link below to start your download _____
https://ebookmass.com/product/beginning-c-compilers-an-
introductory-guide-to-microsoft-c-c-and-mingw-compilers-1st-
edition-tuleuov/
Find ebooks or textbooks at ebookmass.com today!
We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmass.com
to discover even more!
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/
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/
Beginning C: From Beginner to Pro 7th Edition Gonzalez-
Morris
https://ebookmass.com/product/beginning-c-from-beginner-to-pro-7th-
edition-gonzalez-morris/
Beginning C++23 7th Edition Ivor Horton
https://ebookmass.com/product/beginning-c23-7th-edition-ivor-horton-2/
Beginning C++23 7th Edition Ivor Horton
https://ebookmass.com/product/beginning-c23-7th-edition-ivor-horton/
Beginning C: From Beginner to Pro, 7th Edition German
Gonzalez-Morris
https://ebookmass.com/product/beginning-c-from-beginner-to-pro-7th-
edition-german-gonzalez-morris/
Microsoft Visual C# Step by Step, 9th Edition John Sharp
https://ebookmass.com/product/microsoft-visual-c-step-by-step-9th-
edition-john-sharp/
Microsoft Visual C# Step by Step 10th Edition John Sharp
https://ebookmass.com/product/microsoft-visual-c-step-by-step-10th-
edition-john-sharp/
Modern C++ for Absolute Beginners: A Friendly Introduction
to the C++ Programming Language and C++11 to C++23
Standards, 2nd Edition Slobodan Dmitrovi■
https://ebookmass.com/product/modern-c-for-absolute-beginners-a-
friendly-introduction-to-the-c-programming-language-
and-c11-to-c23-standards-2nd-edition-slobodan-dmitrovic/
Beginning C++ Compilers: An Introductory Guide to Microsoft C/C++ and MinGW Compilers 1st Edition Tuleuov
Beginning C++ Compilers: An Introductory Guide to Microsoft C/C++ and MinGW Compilers 1st Edition Tuleuov
Berik I. Tuleuov and Ademi B. Ospanova
Beginning C++ Compilers
An Introductory Guide to Microsoft C/C++ and
MinGW Compilers
Berik I. Tuleuov
Nur-Sultan, Akmolinskaia, Kazakhstan
Ademi B. Ospanova
Nur-Sułtan, Kazakhstan
ISBN 978-1-4842-9562-5 e-ISBN 978-1-4842-9563-2
https://doi.org/10.1007/978-1-4842-9563-2
© Berik I. Tuleuov and Ademi B. Ospanova 2024
This work is subject to copyright. All rights are solely and exclusively
licensed 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.
The use of general descriptive names, registered names, trademarks,
service marks, etc. in this publication does not imply, even in the
absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general
use.
The publisher, the authors, and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
This Apress imprint is published by the registered company APress
Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY
10004, U.S.A.
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.
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), single big ISO image, 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 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 programmers, as it saves a lot of time; in addition, the
created toolkit can be used in the future repeatedly and on a variety of
computers already without spending time, 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.
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.
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.
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.
Contents
1 Files and Devices
1.​
1 File Types and Formats
1.​
2 Executable and Batch Files
1.​
3 System Commands
1.​
4 Mounting Devices
1.​
5 Virtual Devices
1.​
6 Conclusion
2 Software Installation
2.​
1 Overview of Installation Methods
2.​
2 Installation Packages (msi)
2.​
3 Installing with Archives
2.​
4 Installing from Sources
2.​
5 Portable Installation
2.​
6 Best Software Installation Practices for Windows Systems
2.​
7 Conclusion
3 Programming Languages and Software
3.​
1 Programming Languages
3.​
2 C/​
C++
3.​
3 Fortran
3.​
4 Assembly
3.​
5 C#
3.​
6 Conclusion
4 General Build Information
4.​
1 Unix Systems
4.​
1.​
1 GNU Autotools (GNU Build System)
4.​
2 Windows Systems
4.​
2.​
1 nmake Utility
4.​
2.​
2 Visual Studio .​
vcxproj and .​
sln Files
4.​
2.​
3 MSBuild Build System
4.​
3 Cygwin
4.​
4 Cross-Platform Topics
4.​
5 Conclusion
5 Some Useful Open Source Utilities
5.​
1 Far Manager
5.​
1.​
1 Default Installation
5.​
1.​
2 Easy Installation
5.​
1.​
3 Usage
5.​
2 7z
5.​
2.​
1 Default Installation
5.​
2.​
2 Easy Installation
5.​
2.​
3 Usage
5.​
3 Notepad++
5.​
3.​
1 Default Installation
5.​
3.​
2 Easy Installation
5.​
4 lessmsi
5.​
4.​
1 Easy Installation
5.​
4.​
2 Usage
5.​
5 WinCDEmu
5.​
5.​
1 Easy Installation
5.​
5.​
2 Usage
5.​
6 Conclusion
6 Command-Line Interface
6.​
1 Command Interpreter
6.​
1.​
1 Launching and Executing Commands in the Command
Line (Terminal, Console)
6.​
1.​
2 Path Separator
6.​
1.​
3 Windows Standard Command Line
6.​
2 Environment Variables
6.2.1 Modification of the PATH SystemEnvironment Variable
6.​
3 Access Management
6.​
4 ConEmu
6.​
5 Conclusion
7 Integrated Development Environments and Editors
7.​
1 Microsoft Visual Studio
7.​
2 Qt Creator
7.​
3 Code:​
:​
Blocks
7.​
4 Geany
7.​
5 Kate
7.​
6 Conclusion
8 Minimal Systems
8.​
1 MSYS
8.​
2 Default Installation
8.​
3 Easy Installation
8.​
4 Some Tips
8.​
5 MSYS2
8.​
6 Default Installation
8.​
7 Easy Installation
8.​
8 CMake
8.​
9 Default Installation
8.​
10 Easy Installation
8.​
11 Conclusion
9 Compilers
9.​
1 GCC/​
MinGW
9.​
1.​
1 Default Installation
9.​
1.​
2 Building from the Sources
9.​
1.​
3 Easy Installation
9.​
2 Microsoft C/​
C++ Optimizing Compiler
9.​
2.​
1 Default Installation
9.​
2.​
2 Easy Installation (Without Visual Studio)with EWDK
9.​
2.​
3 Using Microsoft C/​
C++ Compiler with EWDK
9.​
2.​
4 Microsoft C/​
C++ Compiler Options
9.​
2.​
5 Using MSBuild with EWDK
9.​
3 Intel C/​
C++ Optimizing Compiler
9.​
4 Conclusion
10 Libraries
10.​
1 Dynamic and Static Libraries
10.​
2 Building Libraries
10.​
3 Creating User Libraries
10.​
4 Conclusion
11 Using Libraries
11.​
1 Linking with Static Libraries
11.​
2 Linking with Dynamic Libraries
11.​
3 Using Libraries from Source Code
11.​
4 Universal CRT Deployment
11.​
5 Conclusion
12 GMP (GNU Multiprecision Library)
12.​
1 Building
12.​
1.​
1 GNU MPFR Library
12.​
2 Example:​Computation of 10 000 000!
12.​
3 Conclusion
13 Crypto++
13.​
1 Building with MinGW
13.​
2 Building with Microsoft C/​
C++ Compiler
13.​
3 Example:​AES Implementation
13.​
4 Conclusion
14 OpenSSL
14.​
1 Building with MinGW
14.​
2 Building with Microsoft C/​
C++ Compiler
14.​
3 Conclusion
15 Process Hacker
15.​
1 Building with Microsoft C/​
C++ Compiler
15.​
1.​
1 Building Driver
15.​
1.​
2 Building Utility
15.​
2 Conclusion
A Appendix
Bibliography
Index
About the Authors
Berik I. Tuleuov
is Senior Lecturer at L. N. Gumilyov Eurasian National University, 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 programming 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.
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.
1
Footnotes
There are a lot of books on the C/C++ languages themselves.
(1)
(2)
© The Author(s), under exclusive license to APress Media, LLC, 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
1. Files and Devices
Berik I. Tuleuov1
and Ademi B. Ospanova2
Nur-Sultan, Akmolinskaia, Kazakhstan
Nur-Sułtan, Kazakhstan
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 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]
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:WindowsSystem32 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 utilities: 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 canbe done both in the graphical
cls
set
echo
cd
dir
path
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 interesting 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 system
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.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:WINDOWSSystem32 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:
clears the console window (clear screen).
sets a value to an environment variable.
echoes its argument value.
changes the working directory (change directory).
types the content of the current directory.
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 assign a path.
[drive2:]path Specifies a physical drive and path you want to assign
to a virtual drive.
/D Deletes a substituted (virtual) drive.
Type SUBST with no parameters to display a list of current virtual drives.
E:Test>
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 programmatically; 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 executable 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
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.
(1)
(2)
© The Author(s), under exclusive license to APress Media, LLC, 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
2. Software Installation
Berik I. Tuleuov1
and Ademi B. Ospanova2
Nur-Sultan, Akmolinskaia, Kazakhstan
Nur-Sułtan, Kazakhstan
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
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 /7 z 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.
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 /7 z (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 /7 z 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 reinstallation after Windows reinstallation, such as
Microsoft Office, Microsoft Visual Studio, Adobe software, etc.
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
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’’ context 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
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 programs, 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
ProgramsSomeUtility-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
ProgramsSomeUtility-X.Y.Zbin directory to the PATH
environment variable. To do this, we will create a batch file
SomeUtility-X.Y.Z.bat : @echo off
set PATH=%~d0ProgramsSomeUtility-
X.Y.Zbin;%PATH%
and place it in the Programsbin 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.
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
Beginning C++ Compilers: An Introductory Guide to Microsoft C/C++ and MinGW Compilers 1st Edition Tuleuov
Figure 2-3 Disk D directory tree
For programs that do not require installation, it is better to allocate
a separate directory, for example, D:Programs .
(1)
(2)
© The Author(s), under exclusive license to APress Media, LLC, 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
3. Programming Languages and Software
Berik I. Tuleuov1
and Ademi B. Ospanova2
Nur-Sultan, Akmolinskaia, Kazakhstan
Nur-Sułtan, Kazakhstan
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
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 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 carefully
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.
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 (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
Figure 3-1 C# program
Figure 3-2 C++ program
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
is calculated and then the result is displayed on the screen (Figures 3-1 and 3-2).
1
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.
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 computational
aspects.
We also mentioned assembly language in the Microsoft implementation—Microsoft
Macro Assembler (MASM).
References
[3] Albahari, Joseph, and Ben Albahari. 2012. C# 5.0 in a Nutshell, 5th ed. O’Reilly.
[4]
Scheinerman, Edward. 2006. C++ for Mathematicians. An Introduction for Students and Professionals,
521. Chapman & Hall-CRC.
[10]
Yan, Song Y. 2013. Computational Number Theory and Modern Cryptography, 425. Wiley.
Footnotes
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:WindowsMicrosoft.NETFrameworkv3.5csc.exe
CSharp.cs
(1)
(2)
© The Author(s), under exclusive license to APress Media, LLC, 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
4. General Build Information
Berik I. Tuleuov1
and Ademi B. Ospanova2
Nur-Sultan, Akmolinskaia, Kazakhstan
Nur-Sułtan, Kazakhstan
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
...
...
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
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:UsersJohn>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
/U Dump inline files
/Y Disable batch-mode
/? Display brief usage message
D:UsersJohn>
4.2.2 Visual Studio .vcxproj and .sln Files
When developing modern software, especially large software, the so-called integrated 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.
4.2.3 MSBuild Build System
In the Microsoft paper “Walkthrough: Using MSBuild to Create a Visual C++ Project” [13], the process of
MSBuild usage in the command line to build a Visual Studio C++ project is demonstrated.
Other documents randomly have
different content
Roll-tobacco, game of, 39.
Rudall, Rev., ghost-layer, 99.
Rules of contrary, game of, 179.
Sailors’ superstitions, 132.
Sancreed, Holy well near, 33.
Scald, charm for, 147.
Scarlet well, 61.
Scat, game of, 177.
Scilly, Christmas custom at, 11;
harvest home, 53;
News rock, 94;
description of islands, 111.
Sennen, twelfth-night at, 16;
legend of cove, 71;
Table Mên, 75.
Shallal, a custom, 166.
She said and she said, game of, 178.
Shingles, charm for, 154.
Ship sail, game of, 186.
Shovel, Sir Cloudesley, wreck of, 115.
Shrove Tuesday, customs, 21.
Sickness, death, burial superstitions, 167.
Sithney, fair at, 52.
Skip-skop night, 5.
Sleeping foot, charm for, 150.
Snail, creep dance, 39;
superstitions, 131, 138.
Snake superstitions, 155.
Solomon had a great dog, game of, 177.
Spider superstition, 60.
Spriggans, 8, 120, 126;
charms to drive away, 127.
Staunch blood, to, 151.
Stephen’s day, St., 14.
Strain, charm for, 150.
Stratton, 4;
legend of, 109.
Superstitions, 130.
Sweethearts, trying for, 3, 16, 25, 33, 42, 165.
Sweet nightingale, ballad, 199.
Talland, legend of, 97.
Taking day, 48.
Tetter, charm for, 149.
Thomasine Bonaventure, 110.
Three dukes a-riding, game of, 172.
Thorn prick, charm for, 148.
Thrush, charm for, 159.
Tibb’s eve, St., 15.
Tintagel, castle of, 57;
superstition at, 155.
Tom Toddy, game, 189.
Toothache, charm for, 149.
Towans, 67.
Towednack, feast of, 28;
legend of, 68.
Trecarrel, of Launceston, legend of, 108.
Tregeagle, legend of, 72.
Tresco (Scilly), Abbey, 113, 117;
gardens, stone in, 114;
Piper’s hole, 115;
witches, 118;
wreckers, ib.
Trevilian, legend of, 67.
Treryn castle, 77.
Troth plight, 114, 153.
Troy-town, 119.
Truro, fair at, 52;
custom at, 103.
Tweedily, tweedily, twee, ballad, 197.
Twelfth-tide customs, 15, 19.
Uncle Jan Dory, rhyme of, 205.
Uny, St., well of, 33, 127.
Uppa, uppa, etc., game formula, 188.
Vellan-drucher Moor, 74.
Veryan, legend of, 102.
Vesey, vasey, game of, 175.
Vizzery, vazzery, game formula, 175.
Vow, the lady of the, 9.
Warleggan, custom at, 9.
Warna’s, St., Holy well, 118.
Warsail boys, 14.
Warts, charms for, 148.
Weigh the butter, game of, 185.
Wesley, Rev. John, ghost story, 99.
When shall we be married? ballad, 198.
White witches, 145.
Whitsuntide customs, 37.
Whisk (whist), 17.
Whooping cough, charms for, 161.
Widow’s superstition, 167.
Wildfire, charm for, 150.
Winkey eye, game of, 188.
Woods, Rev., ghost-layer, 96.
Wreckers, 89.
Wrestling, 37.
Ye sexes give ear, ballad, 195.
Zennor, Christmas custom at, 7;
Midsummereve, 41;
legend of, 70;
old custom at, 166.
Table of Contents
PREFACE.
CORNISH FEASTS AND “FEASTEN” CUSTOMS. 1
LEGENDS OF PARISHES, ETC. 56
Cornwall Stone. 93
FAIRIES. 120
SUPERSTITIONS: Miners’, Sailors’, Farmers’. 130
CHARMS, Etc. 143
For Tetters. 149
Toothache. 149
For a Strain. 150
For Ague. 150
For Wildfire (Erysipelas). 150
CORNISH GAMES. 172
Pray, pretty Miss. 174
“Friskee, friskee, I was, and I was.” 175
“Fool, fool, come to School.” 176
“Scat” (Cornish for “slap”). 177
Hole in the Wall. 177
Malaga, Malaga Raisins (a forfeit game). 177
She Said, and She Said. 178
Drop the Handkerchief. 178
How Many Miles to Babylon? 179
Rules of Contrary. 179
Lady Queen Anne. 179
Old Witch. 180
Ghost at the Well. 182
Mother, Mother, may I go out to Play? 182
Here I sit on a cold green Bank. 183
Joggle along. 184
The Jolly Miller, 184
Bobby Bingo. 185
Weigh the Butter, weigh the Cheese, 185
Libbety, libbety, libbety-lat. 186
Ship Sail 186
Buck shee, buck, 186
Accroshay. 187
Buckey-how. 187
Cutters and Trucklers (Smugglers). 187
Marble Playing 187
Cock-haw. 188
Winky-eye. 188
Uppa, Uppa Holye (pronounced oopa, oopa holly). 188
Tom Toddy, 189
BALLADS, Etc. 190
John Dory. 191
An Old Ballad On a Duke of Cornwall’s Daughter 192
Ye Sexes give ear. 195
A Fox went forth. 196
Tweedily, Tweedily, Twee (North Cornwall). 197
When shall we be Married? 198
Sweet Nightingale. 199
The Stout Cripple of Cornwall. 200
The Baarley Mow (a harvest song). 203
The Long Hundred. 205
Elicompane. 205
Uncle Jan Dory. 205
ADDENDA. 207
INDEX. v
Colophon
Availability
This eBook is for the use of anyone anywhere 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 .
This eBook is produced by the Online Distributed Proofreading Team
at www.pgdp.net .
Scans for this book are available on the Internet Archive (copy 1 ).
Metadata
Title: Cornish Feasts and Folk-lore
Author: Margaret Ann Courtney (1834–
1920)
Info
Language: English
Original publication
date:
1890
Keywords: Cornwall
England
Fasts and feasts
Folklore
Legends
Social life and customs
Catalog entries
Related Library of Congress catalog page: 28031161
Related WorldCat catalog page: 702566
Related Open Library catalog page (for source): OL6723199M
Related Open Library catalog page (for work): OL6665109W
Encoding
Revision History
2017-04-23 Started.
External References
This Project Gutenberg eBook contains external references. These
links may not work for you.
Corrections
The following corrections have been applied to the text:
Page Source Correction Edit
distance
14 [Not in source] ’ 1
24, 24,
141,
208 ” [Deleted] 1
25, 147 [Not in source] “ 1
28 bedroom bed-room 1
72 ther their 1
76 ’ ” 1
105,
144,
173 “ ‘ 1
105,
144,
” ’ 1
173
113 it its 1
120 elfiish elfish 1
128 possiby possibly 1
129 [Not in source] . 1
130 ,’ ’, 2
130 .’ ’. 2
170 [Not in source] , 1
180,
180 courtesy curtsey 3
184 midle middle 1
207 semed seemed 1
208 ancles ankles 1
vi , . 1
Abbreviations
Overview of abbreviations used.
Abbreviation Expansion
4s. 6d. 4 shilling 6 pence
6s. 8d. 6 shilling 8 pence
999l. 19s. 11¾d. 999 pounds 19 shilling 11¾ pence
A.D. [Expansion not available]
B.B. [Expansion not available]
F.L.S. The Folklore Society
F.M. [Expansion not available]
F.R.S. Fellow of the Royal Society
H. G. T. [Expansion not available]
H.R.C. [Expansion not available]
J. H. C. [Expansion not available]
M.A. Master of Arts
M.B. Bachelor of Medicine
Rev. Reverend
St. Saint
T.S.B. [Expansion not available]
W. A. B. C. [Expansion not available]
W. Antiquary Western Antiquary
W. B. [Expansion not available]
*** END OF THE PROJECT GUTENBERG EBOOK CORNISH FEASTS
AND FOLK-LORE ***
Updated editions will replace the previous one—the old editions
will be renamed.
Creating the works from print editions not protected by U.S.
copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.
START: FULL LICENSE
THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK
To protect the Project Gutenberg™ mission of promoting the
free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.
Section 1. General Terms of Use and
Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.
1.B. “Project Gutenberg” is a registered trademark. It may only
be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
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 perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookmasss.com

More Related Content

Similar to Beginning C++ Compilers: An Introductory Guide to Microsoft C/C++ and MinGW Compilers 1st Edition Tuleuov (20)

DOCX
Prg 218 entire course
grades4u
 
PDF
The Development History of PVS-Studio for Linux
PVS-Studio
 
PDF
codeblocks-instructions.pdf
RavinderKSingla
 
PPTX
Session 1 - c++ intro
VijayaNagarajan5
 
PDF
C 10 Pocket Reference Instant Help For C 10 Programmers First Early Release 1...
xutyeie640
 
PDF
Frequently Asked Questions about Adobe Support for Intel based Macs 1st Editi...
leleymvuna
 
PDF
Programming in C++
Lindsey Anderson
 
PDF
What every C++ programmer should know about modern compilers (w/ comments, AC...
Sławomir Zborowski
 
PDF
NET Programming A Practical Guide Using C 1st Edition Pradeep Tapadiya
phatsrla45
 
DOCX
The seven pillars of aspnet
Nethaji Naidu
 
PDF
C in7-days
Sanuj Nair
 
PDF
C in7-days
Amit Kapoor
 
PDF
NET Programming A Practical Guide Using C 1st Edition Pradeep Tapadiya
jgrwvnal9590
 
PPTX
miniproject.pptx
AnkurMahour1
 
DOCX
The Seven Pillars Of Asp.Net
Anand Kumar Rajana
 
PDF
VisualStudioCode-TipsAndTricks-Vol.1.pdf
saimukesh19
 
PDF
Hacking with Spring Boot 2.3: Reactive Edition
honiestruga
 
PDF
NET Programming A Practical Guide Using C 1st Edition Pradeep Tapadiya
miyekeiven
 
PDF
Smiley033
subhajitmondalglb
 
Prg 218 entire course
grades4u
 
The Development History of PVS-Studio for Linux
PVS-Studio
 
codeblocks-instructions.pdf
RavinderKSingla
 
Session 1 - c++ intro
VijayaNagarajan5
 
C 10 Pocket Reference Instant Help For C 10 Programmers First Early Release 1...
xutyeie640
 
Frequently Asked Questions about Adobe Support for Intel based Macs 1st Editi...
leleymvuna
 
Programming in C++
Lindsey Anderson
 
What every C++ programmer should know about modern compilers (w/ comments, AC...
Sławomir Zborowski
 
NET Programming A Practical Guide Using C 1st Edition Pradeep Tapadiya
phatsrla45
 
The seven pillars of aspnet
Nethaji Naidu
 
C in7-days
Sanuj Nair
 
C in7-days
Amit Kapoor
 
NET Programming A Practical Guide Using C 1st Edition Pradeep Tapadiya
jgrwvnal9590
 
miniproject.pptx
AnkurMahour1
 
The Seven Pillars Of Asp.Net
Anand Kumar Rajana
 
VisualStudioCode-TipsAndTricks-Vol.1.pdf
saimukesh19
 
Hacking with Spring Boot 2.3: Reactive Edition
honiestruga
 
NET Programming A Practical Guide Using C 1st Edition Pradeep Tapadiya
miyekeiven
 

Recently uploaded (20)

PPTX
SCHOOL-BASED SEXUAL HARASSMENT PREVENTION AND RESPONSE WORKSHOP
komlalokoe
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
Explorando Recursos do Summer '25: Dicas Essenciais - 02
Mauricio Alexandre Silva
 
PDF
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
PPTX
How to Define Translation to Custom Module And Add a new language in Odoo 18
Celine George
 
PDF
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPTX
Nutri-QUIZ-Bee-Elementary.pptx...................
ferdinandsanbuenaven
 
PPTX
How to Manage Promotions in Odoo 18 Sales
Celine George
 
PPTX
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
PDF
The-Beginnings-of-Indian-Civilisation.pdf/6th class new ncert social/by k san...
Sandeep Swamy
 
PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
PPTX
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
PPTX
LEGAL ASPECTS OF PSYCHIATRUC NURSING.pptx
PoojaSen20
 
PPTX
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
PPTX
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
PPTX
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
SCHOOL-BASED SEXUAL HARASSMENT PREVENTION AND RESPONSE WORKSHOP
komlalokoe
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Explorando Recursos do Summer '25: Dicas Essenciais - 02
Mauricio Alexandre Silva
 
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
How to Define Translation to Custom Module And Add a new language in Odoo 18
Celine George
 
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
Nutri-QUIZ-Bee-Elementary.pptx...................
ferdinandsanbuenaven
 
How to Manage Promotions in Odoo 18 Sales
Celine George
 
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
The-Beginnings-of-Indian-Civilisation.pdf/6th class new ncert social/by k san...
Sandeep Swamy
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
LEGAL ASPECTS OF PSYCHIATRUC NURSING.pptx
PoojaSen20
 
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
Ad

Beginning C++ Compilers: An Introductory Guide to Microsoft C/C++ and MinGW Compilers 1st Edition Tuleuov

  • 1. Download the full version and explore a variety of ebooks or textbooks at https://ebookmass.com Beginning C++ Compilers: An Introductory Guide to Microsoft C/C++ and MinGW Compilers 1st Edition Tuleuov _____ Tap the link below to start your download _____ https://ebookmass.com/product/beginning-c-compilers-an- introductory-guide-to-microsoft-c-c-and-mingw-compilers-1st- edition-tuleuov/ Find ebooks or textbooks at ebookmass.com today!
  • 2. We believe these products will be a great fit for you. Click the link to download now, or visit ebookmass.com to discover even more! 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/ 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/ Beginning C: From Beginner to Pro 7th Edition Gonzalez- Morris https://ebookmass.com/product/beginning-c-from-beginner-to-pro-7th- edition-gonzalez-morris/ Beginning C++23 7th Edition Ivor Horton https://ebookmass.com/product/beginning-c23-7th-edition-ivor-horton-2/
  • 3. Beginning C++23 7th Edition Ivor Horton https://ebookmass.com/product/beginning-c23-7th-edition-ivor-horton/ Beginning C: From Beginner to Pro, 7th Edition German Gonzalez-Morris https://ebookmass.com/product/beginning-c-from-beginner-to-pro-7th- edition-german-gonzalez-morris/ Microsoft Visual C# Step by Step, 9th Edition John Sharp https://ebookmass.com/product/microsoft-visual-c-step-by-step-9th- edition-john-sharp/ Microsoft Visual C# Step by Step 10th Edition John Sharp https://ebookmass.com/product/microsoft-visual-c-step-by-step-10th- edition-john-sharp/ Modern C++ for Absolute Beginners: A Friendly Introduction to the C++ Programming Language and C++11 to C++23 Standards, 2nd Edition Slobodan Dmitrovi■ https://ebookmass.com/product/modern-c-for-absolute-beginners-a- friendly-introduction-to-the-c-programming-language- and-c11-to-c23-standards-2nd-edition-slobodan-dmitrovic/
  • 6. Berik I. Tuleuov and Ademi B. Ospanova Beginning C++ Compilers An Introductory Guide to Microsoft C/C++ and MinGW Compilers
  • 7. Berik I. Tuleuov Nur-Sultan, Akmolinskaia, Kazakhstan Ademi B. Ospanova Nur-Sułtan, Kazakhstan ISBN 978-1-4842-9562-5 e-ISBN 978-1-4842-9563-2 https://doi.org/10.1007/978-1-4842-9563-2 © Berik I. Tuleuov and Ademi B. Ospanova 2024 This work is subject to copyright. All rights are solely and exclusively licensed 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. The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. The publisher, the authors, and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
  • 8. This Apress imprint is published by the registered company APress Media, LLC, part of Springer Nature. The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.
  • 9. 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.
  • 10. 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), single big ISO image, 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
  • 11. archives, simply by 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 programmers, as it saves a lot of time; in addition, the created toolkit can be used in the future repeatedly and on a variety of computers already without spending time, 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,
  • 12. 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. 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.
  • 13. 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.
  • 14. 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.
  • 15. Contents 1 Files and Devices 1.​ 1 File Types and Formats 1.​ 2 Executable and Batch Files 1.​ 3 System Commands 1.​ 4 Mounting Devices 1.​ 5 Virtual Devices 1.​ 6 Conclusion 2 Software Installation 2.​ 1 Overview of Installation Methods 2.​ 2 Installation Packages (msi) 2.​ 3 Installing with Archives 2.​ 4 Installing from Sources 2.​ 5 Portable Installation 2.​ 6 Best Software Installation Practices for Windows Systems 2.​ 7 Conclusion 3 Programming Languages and Software 3.​ 1 Programming Languages 3.​ 2 C/​ C++ 3.​ 3 Fortran 3.​ 4 Assembly 3.​ 5 C# 3.​ 6 Conclusion 4 General Build Information 4.​ 1 Unix Systems 4.​ 1.​ 1 GNU Autotools (GNU Build System)
  • 16. 4.​ 2 Windows Systems 4.​ 2.​ 1 nmake Utility 4.​ 2.​ 2 Visual Studio .​ vcxproj and .​ sln Files 4.​ 2.​ 3 MSBuild Build System 4.​ 3 Cygwin 4.​ 4 Cross-Platform Topics 4.​ 5 Conclusion 5 Some Useful Open Source Utilities 5.​ 1 Far Manager 5.​ 1.​ 1 Default Installation 5.​ 1.​ 2 Easy Installation 5.​ 1.​ 3 Usage 5.​ 2 7z 5.​ 2.​ 1 Default Installation 5.​ 2.​ 2 Easy Installation 5.​ 2.​ 3 Usage 5.​ 3 Notepad++ 5.​ 3.​ 1 Default Installation 5.​ 3.​ 2 Easy Installation 5.​ 4 lessmsi 5.​ 4.​ 1 Easy Installation 5.​ 4.​ 2 Usage 5.​ 5 WinCDEmu 5.​ 5.​ 1 Easy Installation 5.​ 5.​ 2 Usage 5.​ 6 Conclusion
  • 17. 6 Command-Line Interface 6.​ 1 Command Interpreter 6.​ 1.​ 1 Launching and Executing Commands in the Command Line (Terminal, Console) 6.​ 1.​ 2 Path Separator 6.​ 1.​ 3 Windows Standard Command Line 6.​ 2 Environment Variables 6.2.1 Modification of the PATH SystemEnvironment Variable 6.​ 3 Access Management 6.​ 4 ConEmu 6.​ 5 Conclusion 7 Integrated Development Environments and Editors 7.​ 1 Microsoft Visual Studio 7.​ 2 Qt Creator 7.​ 3 Code:​ :​ Blocks 7.​ 4 Geany 7.​ 5 Kate 7.​ 6 Conclusion 8 Minimal Systems 8.​ 1 MSYS 8.​ 2 Default Installation 8.​ 3 Easy Installation 8.​ 4 Some Tips 8.​ 5 MSYS2 8.​ 6 Default Installation 8.​ 7 Easy Installation
  • 18. 8.​ 8 CMake 8.​ 9 Default Installation 8.​ 10 Easy Installation 8.​ 11 Conclusion 9 Compilers 9.​ 1 GCC/​ MinGW 9.​ 1.​ 1 Default Installation 9.​ 1.​ 2 Building from the Sources 9.​ 1.​ 3 Easy Installation 9.​ 2 Microsoft C/​ C++ Optimizing Compiler 9.​ 2.​ 1 Default Installation 9.​ 2.​ 2 Easy Installation (Without Visual Studio)with EWDK 9.​ 2.​ 3 Using Microsoft C/​ C++ Compiler with EWDK 9.​ 2.​ 4 Microsoft C/​ C++ Compiler Options 9.​ 2.​ 5 Using MSBuild with EWDK 9.​ 3 Intel C/​ C++ Optimizing Compiler 9.​ 4 Conclusion 10 Libraries 10.​ 1 Dynamic and Static Libraries 10.​ 2 Building Libraries 10.​ 3 Creating User Libraries 10.​ 4 Conclusion 11 Using Libraries 11.​ 1 Linking with Static Libraries 11.​ 2 Linking with Dynamic Libraries 11.​ 3 Using Libraries from Source Code
  • 19. 11.​ 4 Universal CRT Deployment 11.​ 5 Conclusion 12 GMP (GNU Multiprecision Library) 12.​ 1 Building 12.​ 1.​ 1 GNU MPFR Library 12.​ 2 Example:​Computation of 10 000 000! 12.​ 3 Conclusion 13 Crypto++ 13.​ 1 Building with MinGW 13.​ 2 Building with Microsoft C/​ C++ Compiler 13.​ 3 Example:​AES Implementation 13.​ 4 Conclusion 14 OpenSSL 14.​ 1 Building with MinGW 14.​ 2 Building with Microsoft C/​ C++ Compiler 14.​ 3 Conclusion 15 Process Hacker 15.​ 1 Building with Microsoft C/​ C++ Compiler 15.​ 1.​ 1 Building Driver 15.​ 1.​ 2 Building Utility 15.​ 2 Conclusion A Appendix Bibliography Index
  • 20. About the Authors Berik I. Tuleuov is Senior Lecturer at L. N. Gumilyov Eurasian National University, 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 programming 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.
  • 21. 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.
  • 22. 1 Footnotes There are a lot of books on the C/C++ languages themselves.
  • 23. (1) (2) © The Author(s), under exclusive license to APress Media, LLC, 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 1. Files and Devices Berik I. Tuleuov1 and Ademi B. Ospanova2 Nur-Sultan, Akmolinskaia, Kazakhstan Nur-Sułtan, Kazakhstan 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 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.
  • 24. 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] 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).
  • 25. 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:WindowsSystem32 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 utilities: 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 canbe done both in the graphical
  • 26. cls set echo cd dir path 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 interesting 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 system 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.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:WINDOWSSystem32 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: clears the console window (clear screen). sets a value to an environment variable. echoes its argument value. changes the working directory (change directory). types the content of the current directory.
  • 27. 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 assign a path. [drive2:]path Specifies a physical drive and path you want to assign to a virtual drive. /D Deletes a substituted (virtual) drive. Type SUBST with no parameters to display a list of current virtual drives. E:Test> 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 programmatically; 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),
  • 28. 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 executable 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 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.
  • 29. (1) (2) © The Author(s), under exclusive license to APress Media, LLC, 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 2. Software Installation Berik I. Tuleuov1 and Ademi B. Ospanova2 Nur-Sultan, Akmolinskaia, Kazakhstan Nur-Sułtan, Kazakhstan 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:
  • 30. 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 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
  • 31. msi but also zip /7 z 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. 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 /7 z (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.
  • 32. 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 /7 z 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 reinstallation after Windows reinstallation, such as Microsoft Office, Microsoft Visual Studio, Adobe software, etc. 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
  • 33. 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 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
  • 34. 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’’ context 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.
  • 35. Figure 2-2 Changing the DVD letter 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 programs, 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 ProgramsSomeUtility-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 ProgramsSomeUtility-X.Y.Zbin directory to the PATH environment variable. To do this, we will create a batch file SomeUtility-X.Y.Z.bat : @echo off
  • 36. set PATH=%~d0ProgramsSomeUtility- X.Y.Zbin;%PATH% and place it in the Programsbin 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. 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
  • 37. 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
  • 38. 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
  • 40. Figure 2-3 Disk D directory tree For programs that do not require installation, it is better to allocate a separate directory, for example, D:Programs .
  • 41. (1) (2) © The Author(s), under exclusive license to APress Media, LLC, 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 3. Programming Languages and Software Berik I. Tuleuov1 and Ademi B. Ospanova2 Nur-Sultan, Akmolinskaia, Kazakhstan Nur-Sułtan, Kazakhstan 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 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.
  • 42. 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 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
  • 43. 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 carefully 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. 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:
  • 44. 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 (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
  • 45. 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 Figure 3-1 C# program Figure 3-2 C++ program 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 is calculated and then the result is displayed on the screen (Figures 3-1 and 3-2).
  • 46. 1 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. 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 computational aspects. We also mentioned assembly language in the Microsoft implementation—Microsoft Macro Assembler (MASM). References [3] Albahari, Joseph, and Ben Albahari. 2012. C# 5.0 in a Nutshell, 5th ed. O’Reilly. [4] Scheinerman, Edward. 2006. C++ for Mathematicians. An Introduction for Students and Professionals, 521. Chapman & Hall-CRC. [10] Yan, Song Y. 2013. Computational Number Theory and Modern Cryptography, 425. Wiley. Footnotes 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:WindowsMicrosoft.NETFrameworkv3.5csc.exe CSharp.cs
  • 47. (1) (2) © The Author(s), under exclusive license to APress Media, LLC, 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 4. General Build Information Berik I. Tuleuov1 and Ademi B. Ospanova2 Nur-Sultan, Akmolinskaia, Kazakhstan Nur-Sułtan, Kazakhstan 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 ... ... 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
  • 48. 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 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:UsersJohn>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
  • 49. /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 /U Dump inline files /Y Disable batch-mode /? Display brief usage message D:UsersJohn> 4.2.2 Visual Studio .vcxproj and .sln Files When developing modern software, especially large software, the so-called integrated 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. 4.2.3 MSBuild Build System In the Microsoft paper “Walkthrough: Using MSBuild to Create a Visual C++ Project” [13], the process of MSBuild usage in the command line to build a Visual Studio C++ project is demonstrated.
  • 50. Other documents randomly have different content
  • 51. Roll-tobacco, game of, 39. Rudall, Rev., ghost-layer, 99. Rules of contrary, game of, 179. Sailors’ superstitions, 132. Sancreed, Holy well near, 33. Scald, charm for, 147. Scarlet well, 61. Scat, game of, 177. Scilly, Christmas custom at, 11; harvest home, 53; News rock, 94; description of islands, 111. Sennen, twelfth-night at, 16; legend of cove, 71; Table Mên, 75. Shallal, a custom, 166. She said and she said, game of, 178. Shingles, charm for, 154. Ship sail, game of, 186. Shovel, Sir Cloudesley, wreck of, 115. Shrove Tuesday, customs, 21. Sickness, death, burial superstitions, 167. Sithney, fair at, 52.
  • 52. Skip-skop night, 5. Sleeping foot, charm for, 150. Snail, creep dance, 39; superstitions, 131, 138. Snake superstitions, 155. Solomon had a great dog, game of, 177. Spider superstition, 60. Spriggans, 8, 120, 126; charms to drive away, 127. Staunch blood, to, 151. Stephen’s day, St., 14. Strain, charm for, 150. Stratton, 4; legend of, 109. Superstitions, 130. Sweethearts, trying for, 3, 16, 25, 33, 42, 165. Sweet nightingale, ballad, 199. Talland, legend of, 97. Taking day, 48. Tetter, charm for, 149. Thomasine Bonaventure, 110. Three dukes a-riding, game of, 172.
  • 53. Thorn prick, charm for, 148. Thrush, charm for, 159. Tibb’s eve, St., 15. Tintagel, castle of, 57; superstition at, 155. Tom Toddy, game, 189. Toothache, charm for, 149. Towans, 67. Towednack, feast of, 28; legend of, 68. Trecarrel, of Launceston, legend of, 108. Tregeagle, legend of, 72. Tresco (Scilly), Abbey, 113, 117; gardens, stone in, 114; Piper’s hole, 115; witches, 118; wreckers, ib. Trevilian, legend of, 67. Treryn castle, 77. Troth plight, 114, 153. Troy-town, 119. Truro, fair at, 52; custom at, 103. Tweedily, tweedily, twee, ballad, 197.
  • 54. Twelfth-tide customs, 15, 19. Uncle Jan Dory, rhyme of, 205. Uny, St., well of, 33, 127. Uppa, uppa, etc., game formula, 188. Vellan-drucher Moor, 74. Veryan, legend of, 102. Vesey, vasey, game of, 175. Vizzery, vazzery, game formula, 175. Vow, the lady of the, 9. Warleggan, custom at, 9. Warna’s, St., Holy well, 118. Warsail boys, 14. Warts, charms for, 148. Weigh the butter, game of, 185. Wesley, Rev. John, ghost story, 99. When shall we be married? ballad, 198. White witches, 145. Whitsuntide customs, 37. Whisk (whist), 17. Whooping cough, charms for, 161. Widow’s superstition, 167.
  • 55. Wildfire, charm for, 150. Winkey eye, game of, 188. Woods, Rev., ghost-layer, 96. Wreckers, 89. Wrestling, 37. Ye sexes give ear, ballad, 195. Zennor, Christmas custom at, 7; Midsummereve, 41; legend of, 70; old custom at, 166.
  • 56. Table of Contents PREFACE. CORNISH FEASTS AND “FEASTEN” CUSTOMS. 1 LEGENDS OF PARISHES, ETC. 56 Cornwall Stone. 93 FAIRIES. 120 SUPERSTITIONS: Miners’, Sailors’, Farmers’. 130 CHARMS, Etc. 143 For Tetters. 149 Toothache. 149 For a Strain. 150 For Ague. 150 For Wildfire (Erysipelas). 150 CORNISH GAMES. 172 Pray, pretty Miss. 174 “Friskee, friskee, I was, and I was.” 175 “Fool, fool, come to School.” 176 “Scat” (Cornish for “slap”). 177 Hole in the Wall. 177 Malaga, Malaga Raisins (a forfeit game). 177 She Said, and She Said. 178 Drop the Handkerchief. 178 How Many Miles to Babylon? 179 Rules of Contrary. 179
  • 57. Lady Queen Anne. 179 Old Witch. 180 Ghost at the Well. 182 Mother, Mother, may I go out to Play? 182 Here I sit on a cold green Bank. 183 Joggle along. 184 The Jolly Miller, 184 Bobby Bingo. 185 Weigh the Butter, weigh the Cheese, 185 Libbety, libbety, libbety-lat. 186 Ship Sail 186 Buck shee, buck, 186 Accroshay. 187 Buckey-how. 187 Cutters and Trucklers (Smugglers). 187 Marble Playing 187 Cock-haw. 188 Winky-eye. 188 Uppa, Uppa Holye (pronounced oopa, oopa holly). 188 Tom Toddy, 189 BALLADS, Etc. 190 John Dory. 191 An Old Ballad On a Duke of Cornwall’s Daughter 192 Ye Sexes give ear. 195 A Fox went forth. 196 Tweedily, Tweedily, Twee (North Cornwall). 197 When shall we be Married? 198 Sweet Nightingale. 199 The Stout Cripple of Cornwall. 200 The Baarley Mow (a harvest song). 203
  • 58. The Long Hundred. 205 Elicompane. 205 Uncle Jan Dory. 205 ADDENDA. 207 INDEX. v
  • 59. Colophon Availability This eBook is for the use of anyone anywhere 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 . This eBook is produced by the Online Distributed Proofreading Team at www.pgdp.net . Scans for this book are available on the Internet Archive (copy 1 ). Metadata Title: Cornish Feasts and Folk-lore Author: Margaret Ann Courtney (1834– 1920) Info Language: English Original publication date: 1890 Keywords: Cornwall England Fasts and feasts Folklore Legends Social life and customs Catalog entries
  • 60. Related Library of Congress catalog page: 28031161 Related WorldCat catalog page: 702566 Related Open Library catalog page (for source): OL6723199M Related Open Library catalog page (for work): OL6665109W Encoding Revision History 2017-04-23 Started. External References This Project Gutenberg eBook contains external references. These links may not work for you. Corrections The following corrections have been applied to the text: Page Source Correction Edit distance 14 [Not in source] ’ 1 24, 24, 141, 208 ” [Deleted] 1 25, 147 [Not in source] “ 1 28 bedroom bed-room 1 72 ther their 1 76 ’ ” 1 105, 144, 173 “ ‘ 1 105, 144, ” ’ 1
  • 61. 173 113 it its 1 120 elfiish elfish 1 128 possiby possibly 1 129 [Not in source] . 1 130 ,’ ’, 2 130 .’ ’. 2 170 [Not in source] , 1 180, 180 courtesy curtsey 3 184 midle middle 1 207 semed seemed 1 208 ancles ankles 1 vi , . 1 Abbreviations Overview of abbreviations used. Abbreviation Expansion 4s. 6d. 4 shilling 6 pence 6s. 8d. 6 shilling 8 pence 999l. 19s. 11¾d. 999 pounds 19 shilling 11¾ pence A.D. [Expansion not available] B.B. [Expansion not available] F.L.S. The Folklore Society F.M. [Expansion not available] F.R.S. Fellow of the Royal Society H. G. T. [Expansion not available] H.R.C. [Expansion not available] J. H. C. [Expansion not available] M.A. Master of Arts
  • 62. M.B. Bachelor of Medicine Rev. Reverend St. Saint T.S.B. [Expansion not available] W. A. B. C. [Expansion not available] W. Antiquary Western Antiquary W. B. [Expansion not available]
  • 63. *** END OF THE PROJECT GUTENBERG EBOOK CORNISH FEASTS AND FOLK-LORE *** Updated editions will replace the previous one—the old editions will be renamed. Creating the works from print editions not protected by U.S. copyright law means that no one owns a United States copyright in these works, so the Foundation (and you!) can copy and distribute it in the United States without permission and without paying copyright royalties. Special rules, set forth in the General Terms of Use part of this license, apply to copying and distributing Project Gutenberg™ electronic works to protect the PROJECT GUTENBERG™ concept and trademark. Project Gutenberg is a registered trademark, and may not be used if you charge for an eBook, except by following the terms of the trademark license, including paying royalties for use of the Project Gutenberg trademark. If you do not charge anything for copies of this eBook, complying with the trademark license is very easy. You may use this eBook for nearly any purpose such as creation of derivative works, reports, performances and research. Project Gutenberg eBooks may be modified and printed and given away—you may do practically ANYTHING in the United States with eBooks not protected by U.S. copyright law. Redistribution is subject to the trademark license, especially commercial redistribution. START: FULL LICENSE
  • 64. THE FULL PROJECT GUTENBERG LICENSE
  • 65. PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK To protect the Project Gutenberg™ mission of promoting the free distribution of electronic works, by using or distributing this work (or any other work associated in any way with the phrase “Project Gutenberg”), you agree to comply with all the terms of the Full Project Gutenberg™ License available with this file or online at www.gutenberg.org/license. Section 1. General Terms of Use and Redistributing Project Gutenberg™ electronic works 1.A. By reading or using any part of this Project Gutenberg™ electronic work, you indicate that you have read, understand, agree to and accept all the terms of this license and intellectual property (trademark/copyright) agreement. If you do not agree to abide by all the terms of this agreement, you must cease using and return or destroy all copies of Project Gutenberg™ electronic works in your possession. If you paid a fee for obtaining a copy of or access to a Project Gutenberg™ electronic work and you do not agree to be bound by the terms of this agreement, you may obtain a refund from the person or entity to whom you paid the fee as set forth in paragraph 1.E.8. 1.B. “Project Gutenberg” is a registered trademark. It may only be used on or associated in any way with an electronic work by people who agree to be bound by the terms of this agreement. There are a few things that you can do with most Project Gutenberg™ electronic works even without complying with the full terms of this agreement. See paragraph 1.C below. There are a lot of things you can do with Project Gutenberg™ electronic works if you follow the terms of this agreement and help preserve free future access to Project Gutenberg™ electronic works. See paragraph 1.E below.
  • 66. 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
  • 67. 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
  • 68. 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
  • 69. 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
  • 70. 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.
  • 71. 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™
  • 72. 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
  • 73. 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
  • 74. 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.
  • 75. Welcome to our website – the perfect destination for book lovers and knowledge seekers. We believe that every book holds a new world, offering opportunities for learning, discovery, and personal growth. That’s why we are dedicated to bringing you a diverse collection of books, ranging from classic literature and specialized publications to self-development guides and children's books. More than just a book-buying platform, we strive to be a bridge connecting you with timeless cultural and intellectual values. With an elegant, user-friendly interface and a smart search system, you can quickly find the books that best suit your interests. Additionally, our special promotions and home delivery services help you save time and fully enjoy the joy of reading. Join us on a journey of knowledge exploration, passion nurturing, and personal growth every day! ebookmasss.com