Boost Users :
From: Andrew McFarlane (andrew.mcfarlane52_at_[hidden])
Date: 2020-02-29 06:44:18
As the subject line suggests, I am attempting to manually employ a master
test suite that registers several sub test suites.
- Each subtest suite has its own header and translation unit.
- Each header has a public "init_test_suite()" method and several private
"test_case<number>()" methods, all of which are declared static. The public
method creates a test suite, adds all the test cases for that translation
unit, and adds the suite to the master test suite. This method is intended
to be called from main.cpp.
Here is a simplified version of my main.cpp:
int main(int argc, char *argv, char *envp)
return boost::unit_test::unit_test_main(®ister_test_suites, argc, argv);
Here's the issue. Despite the fact that I have defined BOOST_TEST_NO_MAIN,
it appears that my compiler is still generating 2 objects files for the
main executable entry:
duplicate symbol 'register_test_suites()' in:
duplicate symbol '_main' in:
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
make: *** [execs/main] Error 1
As you might be wondering, all of my test translation units define
BOOST_TEST_DYN_LINK, and none of them define BOOST_TEST_MODULE, as the
I tried removing BOOST_TEST_NO_MAIN from main.cpp but that did not appear
to do anything.
I also tried removing the static and shared Boost.Unit lib files from my
stage/lib directory and rebuilding only the shared version, and that did
not work either.
Also not that my g++ command does have the expected -L and -l flags for
linking with Boost.Test:
I am lost here. No idea why main() is being defined twice.
Thanks in advance.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net