Boost logo

Boost Users :

Subject: [Boost-users] undefined reference to base_object
From: John C (johnc_at_[hidden])
Date: 2010-05-02 10:38:48


I am working with the boost 1.40.0 serialization library and I am having
trouble with class registration for polymorphic types. The code I have has
worked fine with VS2005 and VS2008 for a long time; however, in linux with
gcc (4.4.1-4ubuntu9), I am having issues.

I am using the non-intrusive serialization method on a class that resides in
a shared object file. I have simplified this down to where the serialization
of the object is performed in an executable linking in the shared object
file. In Windows I am registering the classes with boost using
BOOST_CLASS_EXPORT_GUID. However, in linux, if I register the classes using
this macro, the code compiles but does not link and gives an error similar
to below for :

testConfig.o: In function
`boost::archive::detail::iserializer<boost::archive::text_iarchive,
MyNamespace::MyDerivedClass>::load_object_data(boost::archive::detail::basic_iarchive&,
void*, unsigned int) const':
testConfig.cpp:(.text._ZNK5boost7archive6detail11iserializerINS0_13text_iarchiveEN7MoreOfMyClassRelatredDataEE16load_object_dataERNS1_14basic_iarchiveEPvj[boost::archive::detail::iserializer<boost::archive::text_iarchive,
MyNamespace::MyDerivedClass>::load_object_data(boost::archive::detail::basic_iarchive&,
void*, unsigned int) const]+0x96): undefined reference to
`MyNamespace::MyBaseClass&
boost::serialization::base_object<MyNamespace::MyBaseClass,
MyNamespace::MyDerivedClass>(MyNamespace::MyDerivedClass const&)'

The same error also occurs with save_object_data.

If I don't register, my test fails with the unregistered class exception. I
have tried placing the macros in both a header and a source file and I still
get the linker errors following advice from here:
http://www.boost.org/doc/libs/1_40_0/libs/serialization/doc/special.html#export.
I also tried explicitly instantiating the base_object methods, but get an
error indicating no matching definition exists, so I am assuming this is
related to the issue - I'm just not sure how else to define the function. I
am familiar with basic templating, but the serialization library source is
beyond me.

Any help would be greatly appreciated.....

Thanks - John

-- 
View this message in context: http://old.nabble.com/undefined-reference-to-base_object-tp28417529p28417529.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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