Home | Libraries | People | FAQ | More |
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:
BOOST_AFIO_USE_BOOST_THREAD
(defaults to 0 except on Mingw32 only, Mingw-w64 has a working std thread
library): Use Boost instead of the C++ 11 STL for atomic, chrono, future,
mutex and thread. This is useful where your C++ 11 STL is deficient or
where Boost's facilities are more useful.
BOOST_AFIO_USE_BOOST_FILESYSTEM
(defaults to 0 except on VS2015 and later): Use Boost.Filesystem
instead of the C++ 1y Filesystem TS provided by your STL. As currently
only VS2015 provides Filesystem, it only defaults to 1 for that platform.
ASIO_STANDALONE
(defaults
to undefined): Use standalone ASIO instead of Boost.ASIO.
You will need to provide a copy of standalone ASIO on your include path.
If you wish to run unit tests, you may also adjust:
BOOST_AFIO_USE_BOOST_UNIT_TEST
(defaults to 0): Use Boost.Test
instead of Boost.APIBind's
emulation based on https://github.com/philsquared/Catch.
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
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:
git
submodule update
--init
--recursive
to have git fill in the submodules.
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.
If you'd also like to execute the unit test suite, do:
./b2 libs/afio/test cxxflags=-std=c++11
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.
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:
fsync()
.
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.