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.
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: www.cmake.org
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.
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.
If you’re on Windows then you can configure and build the examples using Visual Studio as follows:
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.