Boost logo

Boost Users :

From: Michael Seibt (m.seibt_at_[hidden])
Date: 2008-04-23 16:45:38


Robert Ramey wrote:
> Peter Dimov wrote:
> > Robert Ramey:
> >> Peter Dimov wrote:
> >
> >> I believe that making a *.cpp file with the macros
> >> BOOST_CLASS_EXPORT(T) would be exactly equivalent to the above.
> >
> > Well, it depends on where the .cpp file is. If it's part of the static
> > library, it will not be included by the linker because there are no
> > references to it. But it is true that
>
> What I meant was that if you want to make sure the stuff in the
> static library is linked in, just make a small *.cpp file as part
> of your main program which includes the BOOST_CLASS_EXPORT
> macros.
>
> #include "a.hpp"
> #include "b.hpp"
> ...
>
> BOOST_CLASS_EXPORT(A)
> BOOST_CLASS_EXPORT(B)

This *.cpp file won't be such little! If those headers contained templates each user of the static library had to compile the template instances again. (I have a multitude of executables and dynamic libraries that use the same template code.)

If you have access to the object files linked into this static library you should link them directly into every using project instead of the static library (as suggested in earlier post). MSVC 2005 and 2008 have a linker option that does this trick if the static library is part of the same solution: "Use Library Dependency Inputs" at the tab "Linker | General". (I searched the options several times until I recognized that this option could be relevant...)


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