Boost logo

Boost :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2007-05-15 09:33:39


On May 15, 2007, at 3:33 AM, Jürgen Hunold wrote:
> An'n Dingsdag 15 Mai 2007 hett Vladimir Prus schreven:
>> I believe this is intentional change made in Boost.Test for 1.34,
>> in the
>> interest of making Linux (where 'main' can be in shared library) and
>> Windows (where 'main' cannot be in shared library), uniform.
>
> Yes, that was the intention

I understand the reasoning---uniformity of behavior across
platforms---but I believe this change was a mistake. My rationale
follows.

When linking on Windows, if both a DLL and a static library are
available, which one does the linker choose?

>> However, you'd need to ask Gennadiy how to your tests work now.
>
> Just #define BOOST_TEST_DYN_LINK

For the shared library tests.

For the static library tests, I don't define BOOST_TEST_DYN_LINK, and
I put the .a file directly on the link line instead of using -L and -l.

>
> Taking a look at libs/test/build/Jamfile.v2 reveals
> : usage-requirements
> <define>BOOST_TEST_NO_AUTO_LINK=1
> <link>shared:<define>BOOST_TEST_DYN_LINK=1
>
> which Boost.Build applies automagically ;-))

Users of Boost.Build are isolated from this change are isolated from
the effects of this change due to usage-requirements. usage-
requirements are very cool, but they hide the fact that this change
causes real trouble for people not using Boost.Build. The very simple
line

        g++ mytest.cpp -I $BOOST_HDRDIR -L $BOOST_ROOT/lib -
lboost_unit_test_framework-gcc33-mt-d

fails to link. That's bad for at least two reasons: (1) it's the
first line that someone is likely to write when trying out the unit
test framework, and it's not going to work; (2) it's the line that
most non-BBv2 build systems would produce, because using -L and -l
are the common ways to link against a static library in the Unix
world. Not the *only* way, but the common way. There also doesn't
seem to be any documentation that tells users that this change was
made, or how to link to the Boost unit test framework on a *nix system.

We've already had some user confusion on this change, e.g.,

        http://lists.boost.org/boost-users/2007/05/27716.php

where I stole the link line above. As I was typing this note, I see
another note requesting assistance on getting this library to link.
Not a good sign.
        
I think we should revert this change for 1.34.1, so that main()
appears in both the static and the shared library. This makes the
simple use cases (which used to work!) work again.

        - Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk