Boost questsion: Link error with boost using g++ and serialize

Hi Folks, Strange problem. I have this declared inline in my class header file: friend class boost::serialization::access; template<class Archive> void serialize (Archive &ar, const unsigned int version); { ar & m_name; // std::string } Builds fine, then I move this to my .cpp file and I get a link error. Here is the output from the linker: test.o(.gnu.linkonce.t._ZN5boost13serialization6access9serializeINS_7archive13text_oarchiveEN19test_RT0_j+0x13): In function `void boost::serialization::access::serialize<boost::archive::text_oarchive, Attribute>(boost::archive::text_oarchive&, Attribute&, unsigned)': /usr/include/c++/3.2.2/bits/stl_alloc.h:238: undefined reference to `void Attribute::serialize<boost::archive::text_oarchive>(boost::archive::text_oarchive&, unsigned)' root/abcmn/cmnUtilities/cmnGenericObjects/tests/GenericObjectsTests.o(.gnu.linkonce.t._ZN5boost13serialization6access9serializeINS_7archive13text_oarchiveEN19test_RT0_j+0x13): In function `void boost::serialization::access::serialize<boost::archive::text_iarchive, Attribute>(boost::archive::text_iarchive&, Attribute&, unsigned)': /usr/include/c++/3.2.2/bits/stl_alloc.h:238: undefined reference to `void Attribute::serialize<boost::archive::text_iarchive>(boost::archive::text_iarchive&, unsigned)' collect2: ld returned 1 exit status Any ideas? Thanks, Kauai __________________________________ Do you Yahoo!? Plan great trips with Yahoo! Travel: Now over 17,000 guides! http://travel.yahoo.com/p-travelguide

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 kauai wrote: | Hi Folks, | | Strange problem. | | I have this declared inline in my class header file: | | friend class boost::serialization::access; | template<class Archive> void serialize (Archive &ar, | const unsigned int version); | { | ar & m_name; // std::string | } | | Builds fine, then I move this to my .cpp file and I | get a link error. | | Here is the output from the linker: | | | test.o(.gnu.linkonce.t._ZN5boost13serialization6access9serializeINS_7archive13text_oarchiveEN19test_RT0_j+0x13): | In function `void | boost::serialization::access::serialize<boost::archive::text_oarchive, | Attribute>(boost::archive::text_oarchive&, Attribute&, | unsigned)': | | /usr/include/c++/3.2.2/bits/stl_alloc.h:238: undefined | reference to `void | Attribute::serialize<boost::archive::text_oarchive>(boost::archive::text_oarchive&, | unsigned)' | root/abcmn/cmnUtilities/cmnGenericObjects/tests/GenericObjectsTests.o(.gnu.linkonce.t._ZN5boost13serialization6access9serializeINS_7archive13text_oarchiveEN19test_RT0_j+0x13): | In function `void | boost::serialization::access::serialize<boost::archive::text_iarchive, | Attribute>(boost::archive::text_iarchive&, Attribute&, | unsigned)': | /usr/include/c++/3.2.2/bits/stl_alloc.h:238: undefined | reference to `void | Attribute::serialize<boost::archive::text_iarchive>(boost::archive::text_iarchive&, | unsigned)' | collect2: ld returned 1 exit status this used to happen when running the serialization demo.cpp here in gentoo too this patch: http://gcc.gnu.org/ml/gcc-patches/2004-08/msg00653.html seems to put this to rest now for good hope this helps | | Any ideas? | Thanks, | Kauai | | | | | __________________________________ | Do you Yahoo!? | Plan great trips with Yahoo! Travel: Now over 17,000 guides! | http://travel.yahoo.com/p-travelguide | _______________________________________________ | Boost-users mailing list | Boost-users@lists.boost.org | http://lists.boost.org/mailman/listinfo.cgi/boost-users | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCZt2oUpKYMelfdYERAr1DAJwKcoFQJvwwMybU9Rb5rUsGhR3T/gCdEeSy 761UWKk4Zy8RLVOg8Q/fHDs= =5Qiz -----END PGP SIGNATURE-----
participants (2)
-
Daniel Goller
-
kauai