• Increase font size
  • Default font size
  • Decrease font size

Source Code

This page provides the complete set of source code examples contained within the text of API Design for C++. Feel free to download and play with these samples yourself. They were designed to be as simple as possible, while still being useful and illustrative. Many thanks to the following people who have contributed fixes to the code: Danyu Liu, Steve Sperandeo, Mario Shraiki, and Tomek Drabas.

Build System

I have used the cross-platform CMake build system to facilitate compiling and linking the examples, so they should work on Windows, Mac OS X, and most UNIX operating systems. You will need to download and install CMake for your platform first though, if you don’t already have it installed:

Building From The Command Line (Linux/Mac/Windows)

With the ‘cmake’ command in your path, you can simply do the following to create a set of Makefiles for your platform and then build all of the examples. This should work from a Linux shell, a Mac OS X Terminal, or a Cygwin shell on Windows (when using Cygwin you should use Cygwin’s /usr/bin/cmake version of CMake).

% cd <source-code-root-dir>
% mkdir build
% cd build
% cmake -G "Unix Makefiles" ..
% make

Note, you can also run the configure.sh script in the root directory to create the build directory and perform the cmake command for you.

Building With XCode on Mac OS X

If you prefer to use the XCode IDE on the Mac rather than compile from the Terminal, then you can simply do the following:

% cd <source-code-root-dir>
% mkdir build
% cd build
% cmake -G "Xcode" ..
% open APIBook.xcodeproj

You can then build, run, and debug all of the examples from within XCode.

Build With Visual Studio on Windows

If you’re on Windows then you can configure and build the examples using Visual Studio as follows:

  1. Run the CMake GUI
  2. Specify the root directory of this package as the source location
  3. Create a ‘build’ subdirectory and specify that as the build location
  4. Press the “Configure” button (you may have to press it twice)
  5. Press the “Generate” button

This should generate a Visual Studio solution file called APIBook.sln in the build directory that you specified. You can open that file in Visual Studio to build, run, and debug the examples.

ABOUT THIS SITE

An Application Programming Interface (API) provides a logical interface to a piece of software and hides its internal details. This website is dedicated to a book on designing APIs for C++ and includes articles and links on API development.
 

SOURCE CODE

The book is accompanied by a source code package that contains many of the examples in the text. Download it for free.
 

OTHER BOOKS

Dr. Reddy has also published a computer graphics book called Level of Detail for 3D Graphics. Check it out too!.
 
Copyright (c) 2023 Martin Reddy. All rights reserved. Login