Boost logo

Boost :

From: Sören Freudiger (freud_at_[hidden])
Date: 2007-06-28 08:15:38


Hi out there
We have got folowing problem:

------------------------------------------------------
***TcpEndpoint.h***
...
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>

class TcpEndpoint : public I_Endpoint
{ ... };

#include <boost/serialization/export.hpp>
BOOST_CLASS_EXPORT_GUID(RCF::TcpEndpoint, "RCF::TcpEndpoint")
-------------------------------------------------------

------------------------------------------------------
***a.cpp***
...
#include "./TcpEndpoint.hpp"
...
------------------------------------------------------
***b.cpp***
...
#include "./TcpEndpoint.hpp"
...

------------------------------------------------------
***c.cpp***
...
#include "./TcpEndpoint.hpp"
...

the result of the linker is:
b.o(.bss+0x7b): multiple definition of
`boost::archive::detail::guid_initializer<RCF::TcpEndpoint>::instance'
a.o(.bss+0x0): first defined here

c.o(.bss+0x7b): multiple definition of
`boost::archive::detail::guid_initializer<RCF::TcpEndpoint>::instance'
a.o(.bss+0x0): first defined here

In our structure we ave ONE file containing ALL "BOOST_CLASS_EXPORT_GUID"
for derived classes and that works fine till the third party lib also has
the BOOST_CLASS_EXPORT_GUID macro inside.

All in all we want to have someting like that:

"A.h"
#inlcude "archive_files_and_export.h"
class A : public Base {};
BOOST_CLASS_EXPORT_GUID(A, "A")

"B.h"
#inlcude "archive_files_and_export.h"
class B : public Base {};
BOOST_CLASS_EXPORT_GUID(B, "B")

"C.h"
#inlcude "archive_files_and_export.h"
class C : public Base {};
BOOST_CLASS_EXPORT_GUID(C, "C")

"main.cpp"
#inlcude "A.h"
#inlcude "B.h"
#inlcude "C.h"

int main() {...}

______________________________________

iRMB - Institute for Computational Modeling in Civil Engineering

TU Braunschweig

Pockelsstr. 3 (9th Floor)

D-38106, Braunschweig, Germany

 

phone +49 531/391-7595

fax +49 531/391-7599

email freud_at_[hidden] <mailto:freud_at_[hidden]>

web www.irmb.tu-bs.de <http://www.irmb.tu-bs.de/>

 


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