Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] problem with custom archive type
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-08-26 13:25:16

OK - now your in the import/export conumdrum which can be a huge pain in the

The basic problem is that given header file x.h is used by code which
exports functions
and also by code which imports functions. When exporting, the code has to
attributes declspec(export) and when importing it has to have attributes
The boost way of handling this was defined by John Maddock. This is
described on the
boost web site under "advice for libraries built a compile time" (or
something like that).
It is indispensable that you study this. There is no "cookbook" solution -
you have to
step back and really thiink about this when you are making your own library
component. So,

a) study the documentation described above
b) look into the serialization library code to see how the above technique
is used
c) look a the serialization library tests/examples which refer to makeing
DLL compontents.
I used a technique similar to the above to make these work.
d) now look at your own custom archive and implement these ideas.

There is not real coding, it's just setting up a bunch a macros and giving
sensible names and runnig tests. It is tedious but I see no alternative.

One option is to use the current archive implementations as model/recipe.
I would strongly suggest you consider this. The reason I say this is that
to make the same code importable/exportable, there is a bunch of stuff
you can't do. Puting some code in static libraries and other code
in dynamic libraries is a recipe for excrutiating and endless agony. Think
of it as successful marriage, pick your partner and make it work.

In my view, the whole DLL thing is the triumph of development over
design, it has just grown in response to solving real problems. As
far as I know, C/C++ standards say nothing about this. This doesn't
help either, etc, etc....

I could go on and on about this, but I don't think it would help
anybody much.

Robert Ramey

Kenneth Riddile wrote:
> On 8/25/2010 11:42 PM, Robert Ramey wrote:
> Thanks Robert, that got me one step closer. Now, when anything tries
> to link with the static library that CustomArchive is a part of, I
> get a bunch of unresolved externals like the following
> (rs::InputArchive == CustomArchive):
> 2>renderer.lib(Material.obj) : error LNK2019: unresolved external
> symbol "__declspec(dllimport) protected: __thiscall
> boost::archive::xml_iarchive_impl<class
> rs::InputArchive>::~xml_iarchive_impl<class rs::InputArchive>(void)"

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at