Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Compilation

Boost.AFIO is by default a headers-only library, unless you define the macro BOOST_AFIO_HEADERS_ONLY to zero before including afio.hpp. Users only need to include the library headers in their programs in order to be able to access definitions and algorithms provided by the Boost.AFIO library. No linking against any binaries is required.

As of v1.3 of the engine, Boost.AFIO is now capable of being used standalone with no dependencies. You choose the dependencies by setting the following macros or leaving them default:

If you wish to run unit tests, you may also adjust:

Thanks to Boost.APIBind, if your compiler has inline namespace support, you can multiply use the above four build config macros in any combination you like, including within the same translation unit i.e. a Boost.Thread based AFIO coexists happily with a C++ 11 STL AFIO in the same compiland, and any combination thereof. Simply undefine the old values of the macros, and define new values including afio.hpp afterwards.

If you do make use of Boost.Filesystem in your AFIO build, note that Boost.Filesystem is dependant on Boost.System which will also need to be linked in. On some platforms (e.g. ARM) you may also need Boost.Atomic.

After defining your build macros of choice, making latest AFIO available to your code is as simple as:

#include "boost.afio/include/boost/afio.hpp"     // latest version
#include "boost.afio/include/boost/v1/afio.hpp"  // specific version

if being used standalone or if being used as part of Boost:

#include "boost/afio.hpp"          // latest version
#include "boost/afio/v1/afio.hpp"  // specific version

Supported Compilers And Current Trunk Build And Unit Test State

OS Compiler STL CPU Build Unit tests
Static analysis clang 3.7 tidy + static analyser + GCC 4.8    
 
VS2013    
 
Thread Sanitiser clang 3.4 libstdc++ 4.9 x64  
Valgrind GCC 4.8 libstdc++ 4.8 x64  
Apple Mac OS X 10.9 clang 3.5 libc++ x64
Android 5.0 clang 3.5 libc++ x86
GCC 4.8 libc++ x86
FreeBSD 10.1 on ZFS clang 3.4 libc++ x86
Ubuntu Linux 12.04 LTS clang 3.3 libstdc++ 4.8 x86
clang 3.4 libstdc++ 4.8 x86
Ubuntu Linux 14.04 LTS clang 3.5 libstdc++ 4.9 x64
clang 3.5 libstdc++ 4.9 ARMv7
clang 3.6 libstdc++ 4.9 x64
clang 3.7 libstdc++ 4.9 x64
GCC 4.8 libstdc++ 4.8 x64
GCC 4.9 libstdc++ 4.9 x64
GCC 4.9 libstdc++ 4.9 ARMv7
GCC 5.1 libstdc++ 5.1 x64
Microsoft Windows 8.1 Mingw-w64 GCC 4.8 libstdc++ 4.8 x64
Visual Studio 2015 Dinkumware x64

Boost AFIO Installation into Boost

As of v1.3 of the engine, you can simply download the afio stable tarball (same as git clone Boost.AFIO followed by a git submodules recursive update and init) and get to work. If however you wish to use AFIO as part of the Boost libraries, AFIO is also a Boost module:

  1. Download the latest version of the Boost Libraries from boost.org. At the time of writing the current version is Boost 1.59. Installing AFIO as a Boost module is not compatible with versions of Boost earlier than 1.56 as this was the first Boost version to become source code modularised.
  2. Download the latest Boost AFIO stable tarball from https://boostgsoc13.github.io/boost.afio/afio-stable.tar.bz2. We do however recommend using the git repository, as it will allow for future updates. If you are unfamiliar with git, check the github website for instructions on how to use git. This is a good place to start: https://help.github.com/articles/set-up-git. Don't forget that after cloning you need to do a git submodule update --init --recursive to have git fill in the submodules.
  3. Assuming that your copy of Boost lives at /home/ned/boost do:
    cd /home/ned/boost/libs
    tar jxf afio-stable.tar.bz2 afio
    cd ..
    ./b2 headers
    ./b2 libs/afio/build cxxflags=-std=c++11
    

    On Microsoft Windows it's almost the same, just don't specify the -std=c++11 if you are using VS2015. Note if you forget the -std currently you need to wipe the bin.v2 directory to reset it as the result is cached by Boost.Build.

  4. If you'd also like to execute the unit test suite, do:

    ./b2 libs/afio/test cxxflags=-std=c++11
    
  5. Similar if you'd like to build documentation, do:

    cd doc
    ../b2 ../libs/afio/doc
    ../b2 ../libs/afio/doc pdf
    

    I may be missing something, but the pdf appears inside bin.v2, not in pdf for some reason. Note that the PDF has some significant formatting problems.

  6. Thanks to modular Boost, AFIO is now exactly the same as any other Boost library and can be used in exactly the same way as if AFIO were already part of Boost.

Running the Unit Tests

To run the unit tests as a standalone build, something like this will probably work for POSIX (it will default to clang on FreeBSD):

./standalone_alltests_gcc.sh
./test_all

Note this has a dependency on Boost.Filesystem as libstdc++ 4.9 (the last I tested) has insufficient Filesystem support. For VS2015:

standalone_alltests_msvc.bat
test_all.exe

VS2015 ships with Filesystem, so this is totally standalone.

To run the unit tests under Boost with bjam, run from the boost top directory:

./b2 libs/afio/test cxxflags=-std=c++11

This will run the entire suite of unit tests. Some useful command line arguments for Boost.Build:

For example:

    b2 link=static toolset=gcc-5 cxxflags=-std=c++1z --test="first_test.cpp second_test.cpp"

will only compile and run only the tests in first_test.cpp and second_test.cpp. All other unit tests will be ignored, and all other command-line options still apply.


PrevUpHomeNext