Boost logo

Boost Users :

From: Richard Jennings (Richard.Jennings_at_[hidden])
Date: 2005-08-04 10:26:57


My application that works with 1.32 is failing to link with 1.33 RC1 due
to boost::serialization::void_cast_register (specialised for my classes)
being an unresolved external.
 
In my case the void_cast_register call and the BOOST_CLASS_EXPORT macro
are in one module while the serialization is done in another module,
with all modules linked in one application.
 
The code below also shows this problem, however if I add an archive
class and header to the example then it will compile and link ok.
Obviously this is when serialization is in the same module as the
void_cast_register call.
 
Any suggestions about what I need to add to make the application link?

Richard

************************************************************************
*******
#pragma hdrstop
#include <boost/serialization/is_abstract.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/export.hpp>
#pragma link "libboost_serialization-bcb-mt-d-1_33.lib"
 
class Z
{
  public:
    virtual void DoSomething() =0;
};
BOOST_IS_ABSTRACT(Z)
 
class A : public Z
{
  public:
    void DoSomething(){};
private:
    friend class boost::serialization::access;
    template<class Archive>
    void serialize(Archive & ar, const unsigned intversion)
    {
      ar & boost::serialization::make_nvp("A", m_A);
    }
 
    int m_A;
};
class B : public Z
{
  public:
    void DoSomething(){};
private:
    friend class boost::serialization::access;
    template<class Archive>
    void serialize(Archive & ar, const unsigned intversion)
    {
      ar & boost::serialization::make_nvp("B", m_B);
    }
 
    int m_B;
};
 
BOOST_CLASS_EXPORT(A)
BOOST_CLASS_EXPORT(B)
 
int main(int argc, char* argv[])
{
  boost::serialization::void_cast_register<A, Z>(0,0);
  boost::serialization::void_cast_register<B, Z>(0,0);
 

  return 0;
}

Errors:
  [Linker Error] Unresolved external 'const
boost::serialization::void_cast_detail::void_caster&
boost::serialization::void_cast_register<A, Z>(const A *, const Z *)'
referenced from D:\PROJECTS\...\SOURCE\TEST\BUILD\MAIN.OBJ
  [Linker Error] Unresolved external 'const
boost::serialization::void_cast_detail::void_caster&
boost::serialization::void_cast_register<B, Z>(const B *, const Z *)'
referenced from D:\PROJECTS\...\SOURCE\TEST\BUILD\MAIN.OBJ


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