Boost C++ Libraries Home Libraries People FAQ More



To use the implementation of main provided by Boost.Test, exactly one source file must define BOOST_TEST_MAIN before including <boost/test/unit_test.hpp>. If multiple source files define BOOST_TEST_MAIN, then a multiply defined symbol error will occur during linking.

If BOOST_TEST_NO_MAIN is defined, then no implementation of main will be provided and the test executable must provide an initialization function. The exact initialization function that must be provided varies depending on how the library is compiled. The details are shown in the discussion of each compilation variation.

When Boost.Test is compiled as a library, BOOST_TEST_NO_MAIN must be defined when the library is compiled for it to work properly in those circumstances.