C++ references and education
- The Definitive C++ Book Guide and List if you are either learning C++ or like hard-copy reference material
- cppreference.com as your casual everyday C++ reference for the language, standard library, and C reference
- C++11 Standard Draft (PDF) as your hardcore C++ reference. (The actual standard costs $200, but you don’t need it unless you’re writing a compiler.)
- Compiler Explorer for learning and researching what assembly your compiler generates
- C++ FAQ for sorting out common confusion of C++ concepts
- C++ Core Guidelines if you’re a perfectionist. Don’t waste too much time following every detail.
- GCC manual: Familiarize yourself with the Table of Contents at least, and you’ll have a much better experience using GCC.
- Clang manual: Leaves out a lot IMO, but most of the features are supposed to behave like GCC with the same flags.
Summary of GCC/Clang flags
-I<path>: Sets the include search directory.
-l<library>: Links to a library. E.g.
dylib) in the linker path set with
-D<macro>[=<value>]: Defines a macro. E.g.
-Wall -Wextra: Enables lots of warnings.
-std=<standard>: Selects a C/C++ standard. E.g.
-O3: Enables most C++ standard-compliant optimizations implemented by the compiler.
-ffast-math: Enables lots of optimizations that break the C++ and IEEE 754 standards.
-march=<arch>: Allow the compiler to generate instructions from certain x86_64 instructions supported by this list of architectures.
-c: Generates a
.oobject file. Without this, GCC invokes the linker after compiling the given input files.
To build a runnable binary or shared library (
.so on Linux,
.dylib on Mac,
.dll on Windows), you can use a linker to combine the object files into an executable container (ELF on Linux, Mach-O on Mac, and PE on Windows).
.a libraries are simply archives of object files combined with the
ar utility. Thus you can simply add them as an input file when linking, e.g.
gcc -o main main.cpp libfoo.a