Boost logo

Boost Users :

From: Florian Winter (fw_at_[hidden])
Date: 2008-06-04 04:15:00

We are trying to write units tests using the Boost.test framework which
involve dynamic loading of libraries (i.e. lt_dlopen on Linux or
LoadLibrary on Windows) and doing tests using the Boost test tools in
code inside the dynamically loaded library.

Does Boost.Test support this?

We have run into problems when trying to use the quick-and-dirty
"include" option for defining the Boost.Test symbols. Dynamically loaded
libraries may not contain undefined symbols, and including the
implementation headers such as <boost/test/included/unit_test.hpp> in
both the dynamically loaded library and the main application seems to
lead to duplicate symbols. In particular, if we use BOOST_CHECK macros
in both the main application, everything works fine. However, if we use
BOOST_CHECK macros in the dynamically loaded library, we get an
exception with the following comment:

    can't use testing tools before framework is initialized

We suspect that this is caused by Boost.Test global symbols being
defined multiple times - once in the application and once in the dynamic

We would like to know what is the "best" practice to use Boost.Test in
unit tests that require dynamic loading of libraries and tests being
made in both application code and dynamic library code. It must work on
Linux (using libraries created with libtool and libltdl for dynamic
loading) and Windows (using DLLs and LoadLibrary for dynamic loading).
Is this even possible and has it been tested before? Would using a
static or shared library version of Boost.Test solve our problem? Are
there any other potential pitfalls that we should be aware of?

Thanks in advance for your help.

Best Regards,

Florian Winter, Motama GmbH

Florian Winter

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at