Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Test - problems overriding main
From: ramonpadilla1_at_[hidden]
Date: 2015-09-03 15:21:21


>________________________________
> From: Gennadiy Rozental <rogeeff_at_[hidden]>
>To: boost-users_at_[hidden]
>Sent: Wednesday, 2 September 2015, 19:48
>Subject: Re: [Boost-users] Boost.Test - problems overriding main
>
>
><ksl <at> yahoo.co.uk> writes:
>
>>
>> I want to provide my own main function while using Boost.Test.
>
>Please take a look at new docs for detailed explanation on this subject
>with examples.

OK.

>> So I have included the following macros:>>
>> #define BOOST_TEST_ALTERNATIVE_INIT_API
>> #define BOOST_TEST_NO_MAIN
>>
>> but this gives me the following error when build on OS X using Xcode 6:
>>
>> Undefined symbols for architecture x86_64:
>> "boost::unit_test::unit_test_main(bool (*)(), int, char**)",
>referenced from:
>> _main in main.o
>
>This is because your library was built without BOOST_TEST_ALTERNATIVE_INIT_API.

Having looked at the documentation, it suggests that I only need to build the library with BOOST_TEST_NO_MAIN if I want to supply my own main. Why do I also need to also build with BOOST_TEST_ALTERNATIVE_INIT_API?

>>
>> I found out that including the following file:
>>
>> #include <boost/test/included/unit_test.hpp>
>

>Single header version will work indeed.

I'm not sure I understand. Can you elaborate?

>>
>> resolves this problem but I'm confused about the implications.
>
>Your only implication is that you will have to spend a bit more time on
>compilation (maybe negligible, if you have enough power) and you have to
>stick with single file test modules.

Again, can you please elaborate?

And just to clarify, if I want to provide my own main function, I *must* build the library with at least BOOST_TEST_NO_MAIN. Under what circumstances would I also build it with BOOST_TEST_ALTERNATIVE_INIT_API?


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