Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-02-11 16:26:35


JOAQUIN LOPEZ MU?Z wrote:
> Hello RObert,
>
> ----- Mensaje original -----
> De: Robert Ramey <ramey_at_[hidden]>
> Fecha: Sábado, Febrero 11, 2006 8:56 pm
> Asunto: Re: [boost] [serialization] serialization/nvp.hppmakes
> autolink kickin
>
>> JOAQUIN LOPEZ MU?Z wrote:
>>> Maybe the following:
>>>
>>> #include <boost/serialization/nvp.hpp>
>>> // rest of serialization headers which must not trigger autolink
>>> #include <...>
>>>
>>> int some_function_already present_in_serialization()
>>> {
>>> }
>>>
>>> int main(){}
>>>
>>> So, if autolink kicks in, the linker will complain about
>>> a duplicate symbol.
>>
>> Hmmm - I wasn't aware that all linkers complain on duplicate symbols
>> rather than just loading missing ones.
>
> Well, you're right the std does not mandate that
> a diagnostic be emitted in such case of ODR violation,
> though most linkers will do.
>
> Anyway, I thibk you can do it in a more robust
> manner:
>
> #include <boost/serialization/nvp.hpp>
> // rest of serialization headers which must not trigger autolink
> #include <...>
>
> // declare some function of the serialization
> // lib (which shouldn't be linked)
>
> int some_f();
>
> int main()
> {
> // use the function in whatever manner
> int x=some_f();
> }
>
> Now, if autolink does not get activated, the
> program should fail as some_f is not linked in.
> So, in your Jamfile just mark this as a link-fail:
>
> [ link-fail auto_link_not_invoked.cpp ]

I didn't know about link-fail - but I'm still missing something here.

If I refer to a function that is declared in one of my headers - then
auto-linking will be triggered. It doesn't matter whether this
reference occurs by taking its address or by invoking it by name.

Now I "think" bjam sets up a path to the directory that contains
my pre-built boost libraries - so the reference will be found
and and the program will link. Its not clear to me that I can
suppress this and guarentee that the link will fail.

Robert Ramey


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