Programming Books

14 Excellent Free Books to Learn C++

Last Updated on June 12, 2023

4. An Introduction to GCC by Brian Gough

An Introduction to GCCAn Introduction to GCC provides an introduction to the GNU C and C++ Compilers, gcc and g++, which are part of the GNU Compiler Collection (GCC).

Many books teach the C and C++ languages, this book teaches you how to use the compiler itself. All the common problems and error messages encountered by new users of GCC are carefully explained, with numerous easy-to-follow “Hello World” examples.

Based on years of observation of questions posted on mailing lists, it guides the reader straight to the important options of GCC. The foreword is written by Richard M. Stallman.


  • Introduction.
  • Compiling a C program – describes how to compile C programs using gcc. Programs can be compiled from a single source file or from multiple source files, and may use system libraries and header files.
  • Compilation options – describes other commonly-used compiler options available in GCC. These options control features such as the search paths used for locating libraries and include files, the use of additional warnings and diagnostics, preprocessor macros and C language dialects.
  • Using the preprocessor – describes the use of the GNU C preprocessor cpp, which is part of the GCC package. The preprocessor expands macros in source files before they are compiled. It is automatically called whenever GCC processes a C or C++ program.
  • Compiling for debugging – provides the -g debug option to store additional debugging information in object files and executables. This debugging information allows errors to be traced back from a specific machine instruction to the corresponding line in the original source file.
  • Compiling with optimization – GCC is an optimizing compiler. It provides a wide range of options which aim to increase the speed, or reduce the size, of the executable files it generates.
  • Compiling a C++ program – describes how to use GCC to compile programs written in C++, and the command-line options specific to that language.
  • Platform-specific options – describes some of the options available for common platforms: Intel and AMD x86 options, x86 extensions, x86 64-bit processors, DEC Alpha options, SPARC options, POWER/PowerPC options, Multi-architecture support, and floating-point issues.
  • Troubleshooting – GCC provides several help and diagnostic options to help troubleshoot problems with the compilation process.
  • Compiler-related tools – describes a number of tools which are useful in combination with GCC. These include the GNU archiver ar, for creating libraries, and the GNU profiling and coverage testing programs, gprof and gcov.
  • How the compiler works – describes in more detail how GCC transforms source files to an executable file. Compilation is a multi-stage process involving several tools, including the GNU Compiler itself (through the gcc or g++ frontends), the GNU Assembler as, and the GNU Linker ld. The complete set of tools used in the compilation process is referred to as a toolchain.
  • Examining compiled files – describes several useful tools for examining the contents of executable files and object files.
  • Common error messages – describes the most frequent error and warning messages produced by gcc and g++. Each case is accompanied by a description of the causes, an example and suggestions of possible solutions.
  • Getting help – if readers encounters a problem not covered by this introduction, there are several reference manuals which describe GCC and language-related topics in more detail.

This book is published under the GNU Free Documentation License.

Read the book

5. An Introduction to Design Patterns in C++ with Qt 4 by Alan Ezust, Paul Ezust

An Introduction to Design Patterns in C++ with Qt 4This book starts with an introduction to the basic C++ elements, OO concepts, UML, and the core Qt classes. It moves on to higher-level programming ideas, Qt modules, and design patterns. The final part of the book examines important C++ features with rigour. There is good coverage on functions, inheritance and polymorphism.

The book is designed to be used in a university class, and assumes no C or C++ programming experience. It includes Qt examples, exercises, solutions, and lecture slides for instructors.

This book is part of Bruce Perens’ Open Source Series. All books in this series are released under the Open Publication License, v1.0 or later.

Read the book

6. C++ Annotations

C++ AnnotationsThe C++ Annotations offers an extensive tutorial about the C++ programming language.

C++ Annotations can be used as a textbook for C++ programming courses.

The C++ Annotations is intended for knowledgeable users of C or a language that uses a C-like grammar. It deliberately doesn’t seek to cover C++’s grammar.

Chapters include:

  • Name Spaces.
  • Strings – C offers rudimentary string support.
  • IO-stream Library – offers an input/output (I/O) library based on class concepts
  • Classes – C offers two methods for structuring data of different types. The C struct holds data members of various types, and the C union also defines data members of various types. This chapter introduces classes, a kind of struct but its contents are by default inaccessible to the outside world.
  • Static Data and Functions.
  • Memory Management – examines the operators that handle memory allocation in C++
  • Exceptions – allow C++ programs to perform a controlled non-local return, without the disadvantages of longjmp and setjmp.
  • Operator Overloading – takes a look at operator overloading in general.
  • Abstract Containers.
  • Inheritance – another term for derivation. The chapter shows that base class pointers may be used to point to derived class objects.
  • Polymorphism – a special form of inheritance.
  • Friends – introduces the friend keyword and the principles that underlie its use.
  • Pointers to Members – defining pointers to members, using pointers to members, pointers to static members, and pointer sizes.
  • Nested Classes – used in situations where the nested class has a close conceptual relationship to its surrounding class.
  • Standard Template Library (STL) – a general purpose library consisting of containers, generic algorithms, iterators, function objects, allocators, adaptors and data structures. The data structures used by the algorithms are abstract in the sense that the algorithms can be used with (practically) any data type.
  • Generic Algorithms – cover the STL’s generic algorithms.
  • Function Templates – explores the syntactic peculiarities of templates. The notions of template type parameter, template non-type parameter, and function template are introduced and several examples of templates are provided.
  • Class Templates – constructing and using class templates is discussed.
  • Advanced Template Use – following a short overview of subtleties related to templates the main characteristics of template meta programming are introduced.

The book is available in HTML, PDF, PostScript, and plain text. It’s freely distributable, and published under the terms of the GNU General Public License.

Read the book

Next page: Page 3 – C++ GUI Programming with Qt 3 and more books

Pages in this article:
Page 1 – The Boost C++ Libraries and more books
Page 2 – An Introduction to GCC and more books
Page 3 – C++ GUI Programming with Qt 3 and more books
Page 4 – Tips and Tricks of the C++ Professionals and more books
Page 5 – How to make an Operating System and more books

All books in this series:

Free Programming Books
AdaALGOL-like programming language, extended from Pascal and other languages
AgdaDependently typed functional language based on intuitionistic Type Theory
ArduinoInexpensive, flexible, open source microcontroller platform
AssemblyAs close to writing machine code without writing in pure hexadecimal
AwkVersatile language designed for pattern scanning and processing language
BashShell and command language; popular both as a shell and a scripting language
BASICBeginner’s All-purpose Symbolic Instruction Code
CGeneral-purpose, procedural, portable, high-level language
C++General-purpose, portable, free-form, multi-paradigm language
C#Combines the power and flexibility of C++ with the simplicity of Visual Basic
ClojureDialect of the Lisp programming language
ClojureScriptCompiler for Clojure that targets JavaScript
COBOLCommon Business-Oriented Language
CoffeeScriptTranscompiles into JavaScript inspired by Ruby, Python and Haskell
CoqDependently typed language similar to Agda, Idris, F* and others
CrystalGeneral-purpose, concurrent, multi-paradigm, object-oriented language
CSSCSS (Cascading Style Sheets) specifies a web page’s appearance
DGeneral-purpose systems programming language with a C-like syntax
DartClient-optimized language for fast apps on multiple platforms
DylanMulti-paradigm language supporting functional and object-oriented coding
ECMAScriptBest known as the language embedded in web browsers
EiffelObject-oriented language designed by Bertrand Meyer
ElixirRelatively new functional language running on the Erlang virtual machine
ErlangGeneral-purpose, concurrent, declarative, functional language
F#Uses functional, imperative, and object-oriented programming methods
FactorDynamic stack-based programming language
ForthImperative stack-based programming language
FortranThe first high-level language, using the first compiler
GoCompiled, statically typed programming language
GroovyPowerful, optionally typed and dynamic language
HaskellStandardized, general-purpose, polymorphically, statically typed language
HTMLHyperText Markup Language
IconWide variety of features for processing and presenting symbolic data
JArray programming language based primarily on APL
JavaGeneral-purpose, concurrent, class-based, object-oriented, high-level language
JavaScriptInterpreted, prototype-based, scripting language
JuliaHigh-level, high-performance language for technical computing
KotlinMore modern version of Java
LabVIEWDesigned to enable domain experts to build power systems quickly
LaTeXProfessional document preparation system and document markup language
LispUnique features - excellent to study programming constructs
LogoDialect of Lisp that features interactivity, modularity, extensibility
LuaDesigned as an embeddable scripting language
MarkdownPlain text formatting syntax designed to be easy-to-read and easy-to-write
Objective-CObject-oriented language that adds Smalltalk-style messaging to C
OCamlThe main implementation of the Caml language
PascalImperative and procedural language designed in the late 1960s
PerlHigh-level, general-purpose, interpreted, scripting, dynamic language
PHPPHP has been at the helm of the web for many years
PostScriptInterpreted, stack-based and Turing complete language
PrologA general purpose, declarative, logic programming language
PureScriptSmall strongly, statically typed language compiling to JavaScript
PythonGeneral-purpose, structured, powerful language
QMLHierarchical declarative language for user interface layout - JSON-like syntax
RDe facto standard among statisticians and data analysts
RacketGeneral-purpose, object-oriented, multi-paradigm, functional language
RakuMember of the Perl family of programming languages
RubyGeneral purpose, scripting, structured, flexible, fully object-oriented language
RustIdeal for systems, embedded, and other performance critical code
ScalaModern, object-functional, multi-paradigm, Java-based language
SchemeA general-purpose, functional language descended from Lisp and Algol
ScratchVisual programming language designed for 8-16 year-old children
SQLAccess and manipulate data held in a relational database management system
Standard MLGeneral-purpose functional language characterized as "Lisp with types"
SwiftPowerful and intuitive general-purpose programming language
TclDynamic language based on concepts of Lisp, C, and Unix shells
TeXMarkup and programming language - create professional quality typeset text
TypeScriptStrict syntactical superset of JavaScript adding optional static typing
ValaObject-oriented language, syntactically similar to C#
VHDLHardware description language used in electronic design automation
VimLPowerful scripting language of the Vim editor
XMLRules for defining semantic tags describing structure ad meaning
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
2 years ago

Hey , thank you for sharing this useful content , highly appreciate.