2 / Copyright (c) 2003 Boost.Test contributors
4 / Distributed under the Boost Software License, Version 1.0. (See accompanying
5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 [section:shared_lib_customizations Shared-library variant customizations]
10 [caution Macro __BOOST_TEST_DYN_LINK__ (which instructs the compiler/linker to dynamically link against a shared library variant) may be implicitly defined when macro `BOOST_ALL_DYN_LINK` is defined.]
12 [caution In order to be able to run a test built with the dynamic variant, the operating system should be able
13 to find the dynamic library of the __UTF__. This means, for example on Linux and MacOSX respectively, setting the environment
14 variable `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` properly prior to the execution of the test module.]
16 [section:entry_point Customizing the module's entry point]
18 In this variant, in one of the source files, you now have to define your custom entry point, and invoke the default [link boost_test.adv_scenarios.test_module_runner_overview test runner] `unit_test_main` manually with the default [link boost_test.adv_scenarios.test_module_init_overview initialization function] `init_unit_test` as argument. You need to define __BOOST_TEST_NO_MAIN__ (its value is irrelevant) in the main file:
21 [[In *exactly one* file][In all other files]]
22 [[```#define BOOST_TEST_MODULE test module name
23 #define BOOST_TEST_DYN_LINK
24 #define BOOST_TEST_NO_MAIN
25 #include <boost/test/unit_test.hpp>
28 int main(int argc, char* argv[], char* envp[])
30 return boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
33 [```#define BOOST_TEST_DYN_LINK
34 #include <boost/test/unit_test.hpp>
46 [endsect] [/section:entry_point]
48 [section:init_func Customizing the module's initialization function]
50 In the shared-library variant, it is impossible to customize the initialization function without [link boost_test.adv_scenarios.shared_lib_customizations.entry_point customizing the entry point]. We have to customize both. In one of the source files, you now have to define your custom entry point and [link boost_test.adv_scenarios.test_module_init_overview initialization function] `init_unit_test`; next invoke the default [link boost_test.adv_scenarios.test_module_runner_overview test runner] `unit_test_main` manually with `init_unit_test` as argument. You ['do not] define __BOOST_TEST_MODULE__ in the main file:
53 [[In *exactly one* file][In all other files]]
54 [[```#define BOOST_TEST_DYN_LINK
55 #include <boost/test/unit_test.hpp>
57 // initialization function:
64 int main(int argc, char* argv[])
66 return boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
69 [```#define BOOST_TEST_DYN_LINK
70 #include <boost/test/unit_test.hpp>
86 [endsect] [/section:init_func]
88 [endsect] [/section:shared_lib_customizations]