|
Boost Users : |
Subject: Re: [Boost-users] Boost.Test with a static library
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2008-11-21 13:58:21
Moritz Beber <moritz.beber <at> googlemail.com> writes:
> Hello everyone,
Hello, guys
I had to step away from support for a bit, but now I am planning to
reply to all the posts.
> after prying for any hints in the documentation
Should probably start here:
http://www.boost.org/doc/libs/1_37_0/libs/test/doc/html/utf/user-guide/usage-variants/static-lib-variant.html
> and reading frustrating mails in the archives for a while now, I get
> the feeling that this is a very confusing topic.
I don't think so. There was some confusion about dynamic library
variant, but the static library was there from the beginning and never
really changed much.
> My aim is to use a static library of boost.test because I need to
> compile it a lot and the waiting time when using the header is just
> frustrating.
Reasonable.
> So I added to the "Jamfile.v2" in "libs/test/build" under "requirements"
> the following line:
> <define>BOOST_TEST_ALTERNATIVE_INIT_API=1
Why? Didn't it work for you out of the box?
> Then I used boost.build and apart from a few warnings like:
> ./boost/test/detail/config.hpp:85:1: warning:
> "BOOST_TEST_ALTERNATIVE_INIT_API" redefined
This is a bit fishy. This place is only related to the dynamic library
variant. Though maybe Boost.Build builds both with single command and
it's fine in that case.
> Then I tried the following code, which I mostly copied from the
> documentation, except for adding two macros:
>
> #define BOOST_TEST_NO_LIB
> #define BOOST_TEST_ALTERNATIVE_INIT_API
> #define BOOST_TEST_MODULE example
> #include <boost/test/unit_test.hpp>
>
> BOOST_AUTO_TEST_SUITE( test_suite1 )
>
> BOOST_AUTO_TEST_CASE( test_case1 )
> {
> BOOST_WARN( sizeof(int) < 4 );
> }
...
>
> When I try to compile, however, I get the following
> error:
>
>
/home/engineer/libs/boost/lib/libboost_unit_test_framework-gcc43-mt-1_37.a(unit_test_main.o):
> In function `main':
> unit_test_main.cpp:(.text+0x2229): undefined reference to
> `init_unit_test()'
> collect2: ld returned 1 exit status
Works fine for me. I just tried and reproduce your exercise.
Maybe clean build would help? Also try to see on results from
preprocessor: check if init_unit_test is there.
Genandiy
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