|
Boost Users : |
From: Brett Gmoser (aftli_at_[hidden])
Date: 2005-05-05 18:10:44
Hello.
I'm trying to use the boost serialization library. I'm using Visual C++ 7.1
under Windows 2000. The Boost.Serialization library seems excellent, and its ease of use is great. However I'm having two problems
with it:
First Problem. Here's the code:
cdx::shrec_script script("");
std::ofstream ofs("compiled_shrec.txt");
boost::archive::text_oarchive oa(ofs);
oa << script; // close archive
ofs.close();
I get an error from boost static_assert, static_assert.hpp (below). Line 437 of regexconv.hpp refers to the "oa << script;"
statement. If I copy the script archive to a new const object:
const cdx::shrec_script temp_script(script);
And try to serialize the temp_script object, the error goes away, and everything (seems to) work okay. I don't really have a
problem with copying it, although it is inconvenient, in order to get this to work. However, the real problem is when I try to
de-serialize the class:
cdx::shrec_script script("");
std::ifstream ifs("compiled_shrec.txt");
boost::archive::text_iarchive oa(ifs);
ia << script; // close archive
ifs.close();
I get the same error (below). This is the big problem, because obviously the object needs to be non-const to be altered with the
new data. I tried doing the same trick as above to get it to work (copy to a const object), but I still get the
STATIC_ASSERTION_FAILURE error.
c:\Boost\include\boost-1_33\boost\archive\detail\oserializer.hpp(551) : error C2027: use of undefined type
'boost::STATIC_ASSERTION_FAILURE<x>'
with
[
x=false
]
c:\Boost\include\boost-1_33\boost\archive\detail\oserializer.hpp(551) : see reference to class template instantiation
'boost::STATIC_ASSERTION_FAILURE<x>' being compiled
with
[
x=false
]
c:\Boost\include\boost-1_33\boost\archive\basic_text_oarchive.hpp(78) : see reference to function template instantiation
'void boost::archive::save<Archive,T>(Archive &,T &)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=cdx::shrec_script
]
c:\Boost\include\boost-1_33\boost\archive\detail\interface_oarchive.hpp(76) : see reference to function template
instantiation 'void boost::archive::basic_text_oarchive<Archive>::save_override<T>(T &,int)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=cdx::shrec_script
]
regexconv.hpp(437) : see reference to function template instantiation 'Archive
&boost::archive::detail::interface_oarchive<Archive>::operator <<<cdx::shrec_script>(T &)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=cdx::shrec_script
]
Second Problem. I'm getting linker errors when trying to compile Boost.Serialization with multi threaded runtimes in VC71. Linker
errors are pasted at the bottom of this message.
Somebody had told me that boost-1.31 and up headers now provide the proper
#pragma for linking with the correct static library automagically, but I
tried adding the #pragma's myself anyway.
I'm not sure exactly what library to link with (there are lots of
libbost_serialization*.lib files), so I tried each one. Each produced
different results with different linker errors ranging from multiply defined
symbols to unresolved externals. One did compile, however:
#pragma comment(lib, "libboost_serialization-vc71-s.lib")
But the program crashes as soon as it is run with the error (an uncaught exception):
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Press any key to continue
I'm assuming this may be related to the fact that the 's' in libboost_serialization-vc71-s.lib means that the lib is compiled for
single threads, and this is a multi threaded program. But of course, I'm probably wrong.
Any light anybody can shed on either of these issues would be greatly appreciated!
Thanks!
Brett
aftli_at_[hidden]
Compiling...
boost_test.cpp
Linking...
Creating library Release/boost_test.lib and object Release/boost_test.exp
boost_test.obj : error LNK2001: unresolved external symbol "private: static
char const * const
boost::serialization::detail::extended_type_info_typeid_0::type_info_key"
(?type_info_key_at_extended_type_info_typeid_0_at_detail@serialization_at_boost@@0PBD
B)
boost_test.obj : error LNK2019: unresolved external symbol "protected:
virtual __thiscall
boost::archive::detail::basic_iarchive::~basic_iarchive(void)"
(??1basic_iarchive_at_detail@archive_at_boost@@MAE_at_XZ) referenced in function
"public: virtual __thiscall boost::archive::detail::common_iarchive<class
boost::archive::text_iarchive>::~common_iarchive<class
boost::archive::text_iarchive>(void)"
(??1?$common_iarchive_at_Vtext_iarchive_at_archive@boost@@@detail_at_archive@boost@@U
AE_at_XZ)
boost_test.obj : error LNK2019: unresolved external symbol "protected:
virtual __thiscall
boost::archive::detail::basic_oarchive::~basic_oarchive(void)"
(??1basic_oarchive_at_detail@archive_at_boost@@MAE_at_XZ) referenced in function
"public: virtual __thiscall boost::archive::detail::common_oarchive<class
boost::archive::text_oarchive>::~common_oarchive<class
boost::archive::text_oarchive>(void)"
(??1?$common_oarchive_at_Vtext_oarchive_at_archive@boost@@@detail_at_archive@boost@@U
AE_at_XZ)
boost_test.obj : error LNK2019: unresolved external symbol "protected: void
__thiscall boost::serialization::extended_type_info::self_register(void)"
(?self_register_at_extended_type_info_at_serialization@boost@@IAEXXZ) referenced
in function "private: __thiscall
boost::serialization::extended_type_info_typeid<class gps_position const
>::extended_type_info_typeid<class gps_position const >(void)"
(??0?$extended_type_info_typeid@$$CBVgps_position@@@serialization_at_boost@@AAE
@XZ)
boost_test.obj : error LNK2019: unresolved external symbol "public: void
__thiscall boost::archive::text_oarchive_impl<class
boost::archive::text_oarchive>::save(class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > const &)"
(?save@?$text_oarchive_impl_at_Vtext_oarchive_at_archive@boost@@@archive_at_boost@@QA
EXABV?$basic_string_at_DU?$char_traits_at_D@std@@V?$allocator_at_D@2@@std@@@Z)
referenced in function "public: static void __cdecl
boost::archive::save_access::save_primitive<class
boost::archive::text_oarchive,class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > >(class
boost::archive::text_oarchive &,class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > const &)"
(??$save_primitive_at_Vtext_oarchive_at_archive@boost@@V?$basic_string_at_DU?$char_tr
aits_at_D@std@@V?$allocator_at_D@2@@std@@@save_access_at_archive@boost@@SAXAAVtext_oa
rchive_at_12@ABV?$basic_string_at_DU?$char_traits_at_D@std@@V?$allocator_at_D@2@@std@@@Z
)
boost_test.obj : error LNK2019: unresolved external symbol "public: void
__thiscall boost::archive::text_iarchive_impl<class
boost::archive::text_iarchive>::load(class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > &)"
(?load@?$text_iarchive_impl_at_Vtext_iarchive_at_archive@boost@@@archive_at_boost@@QA
EXAAV?$basic_string_at_DU?$char_traits_at_D@std@@V?$allocator_at_D@2@@std@@@Z)
referenced in function "public: static void __cdecl
boost::archive::load_access::load_primitive<class
boost::archive::text_iarchive,class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > >(class
boost::archive::text_iarchive &,class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > &)"
(??$load_primitive_at_Vtext_iarchive_at_archive@boost@@V?$basic_string_at_DU?$char_tr
aits_at_D@std@@V?$allocator_at_D@2@@std@@@load_access_at_archive@boost@@SAXAAVtext_ia
rchive_at_12@AAV?$basic_string_at_DU?$char_traits_at_D@std@@V?$allocator_at_D@2@@std@@@Z
)
boost_test.obj : error LNK2019: unresolved external symbol "protected:
__thiscall boost::archive::detail::basic_oarchive::basic_oarchive(void)"
(??0basic_oarchive_at_detail@archive_at_boost@@IAE_at_XZ) referenced in function
"protected: __thiscall boost::archive::detail::common_oarchive<class
boost::archive::text_oarchive>::common_oarchive<class
boost::archive::text_oarchive>(void)"
(??0?$common_oarchive_at_Vtext_oarchive_at_archive@boost@@@detail_at_archive@boost@@I
AE_at_XZ)
boost_test.obj : error LNK2019: unresolved external symbol "protected:
__thiscall boost::archive::detail::basic_iarchive::basic_iarchive(void)"
(??0basic_iarchive_at_detail@archive_at_boost@@IAE_at_XZ) referenced in function
"protected: __thiscall boost::archive::detail::common_iarchive<class
boost::archive::text_iarchive>::common_iarchive<class
boost::archive::text_iarchive>(void)"
(??0?$common_iarchive_at_Vtext_iarchive_at_archive@boost@@@detail_at_archive@boost@@I
AE_at_XZ)
boost_test.obj : error LNK2019: unresolved external symbol "public:
__thiscall boost::archive::basic_text_oprimitive<class
std::basic_ostream<char,struct std::char_traits<char> >
>::~basic_text_oprimitive<class std::basic_ostream<char,struct
std::char_traits<char> > >(void)"
(??1?$basic_text_oprimitive_at_V?$basic_ostream_at_DU?$char_traits_at_D@std@@@std@@@a
rchive_at_boost@@QAE_at_XZ) referenced in function "public: virtual __thiscall
boost::archive::text_oarchive_impl<class
boost::archive::text_oarchive>::~text_oarchive_impl<class
boost::archive::text_oarchive>(void)"
(??1?$text_oarchive_impl_at_Vtext_oarchive_at_archive@boost@@@archive_at_boost@@UAE_at_X
Z)
boost_test.obj : error LNK2019: unresolved external symbol "public:
__thiscall boost::archive::basic_text_iprimitive<class
std::basic_istream<char,struct std::char_traits<char> >
>::~basic_text_iprimitive<class std::basic_istream<char,struct
std::char_traits<char> > >(void)"
(??1?$basic_text_iprimitive_at_V?$basic_istream_at_DU?$char_traits_at_D@std@@@std@@@a
rchive_at_boost@@QAE_at_XZ) referenced in function "public: virtual __thiscall
boost::archive::text_iarchive_impl<class
boost::archive::text_iarchive>::~text_iarchive_impl<class
boost::archive::text_iarchive>(void)"
(??1?$text_iarchive_impl_at_Vtext_iarchive_at_archive@boost@@@archive_at_boost@@UAE_at_X
Z)
boost_test.obj : error LNK2019: unresolved external symbol "protected: void
__thiscall boost::archive::basic_text_iarchive<class
boost::archive::text_iarchive>::load_override(struct
boost::archive::class_name_type &,int)"
(?load_override@?$basic_text_iarchive_at_Vtext_iarchive_at_archive@boost@@@archive
@boost@@IAEXAAUclass_name_type_at_23@H_at_Z) referenced in function "private:
virtual void __thiscall boost::archive::detail::common_iarchive<class
boost::archive::text_iarchive>::vload(struct boost::archive::class_name_type
&)"
(?vload@?$common_iarchive_at_Vtext_iarchive_at_archive@boost@@@detail_at_archive@boos
t@@EAEXAAUclass_name_type_at_34@@Z)
boost_test.obj : error LNK2019: unresolved external symbol "public: void
__thiscall boost::archive::detail::basic_iarchive::load_object(void *,class
boost::archive::detail::basic_iserializer const &)"
(?load_object_at_basic_iarchive_at_detail@archive_at_boost@@QAEXPAXABVbasic_iserializ
er_at_234@@Z) referenced in function "public: static void __cdecl
boost::archive::detail::load_non_pointer_type<class
boost::archive::text_iarchive,class gps_position>::load::invoke(class
boost::archive::text_iarchive &,class gps_position &)"
(?invoke_at_load@?$load_non_pointer_type_at_Vtext_iarchive_at_archive@boost@@Vgps_pos
ition@@@detail_at_archive@boost@@SAXAAVtext_iarchive_at_45@AAVgps_position@@@Z)
boost_test.obj : error LNK2019: unresolved external symbol "public: void
__thiscall boost::archive::detail::basic_oarchive::save_object(void const
*,class boost::archive::detail::basic_oserializer const &)"
(?save_object_at_basic_oarchive_at_detail@archive_at_boost@@QAEXPBXABVbasic_oserializ
er_at_234@@Z) referenced in function "public: static void __cdecl
boost::archive::detail::save_non_pointer_type<class
boost::archive::text_oarchive,class gps_position>::save::invokex(class
boost::archive::text_oarchive &,class gps_position const &)"
(?invokex_at_save@?$save_non_pointer_type_at_Vtext_oarchive_at_archive@boost@@Vgps_po
sition@@@detail_at_archive@boost@@SAXAAVtext_oarchive_at_45@ABVgps_position@@@Z)
boost_test.obj : error LNK2001: unresolved external symbol "struct
boost::archive::version_type const boost::archive::ARCHIVE_VERSION"
(?ARCHIVE_VERSION_at_archive@boost@@3Uversion_type_at_12@B)
boost_test.obj : error LNK2001: unresolved external symbol "char const *
const boost::archive::ARCHIVE_SIGNATURE"
(?ARCHIVE_SIGNATURE_at_archive@boost@@3PBDB)
boost_test.obj : error LNK2019: unresolved external symbol "public:
__thiscall boost::archive::basic_text_oprimitive<class
std::basic_ostream<char,struct std::char_traits<char> >
>::basic_text_oprimitive<class std::basic_ostream<char,struct
std::char_traits<char> > >(class std::basic_ostream<char,struct
std::char_traits<char> > &,bool)"
(??0?$basic_text_oprimitive_at_V?$basic_ostream_at_DU?$char_traits_at_D@std@@@std@@@a
rchive_at_boost@@QAE_at_AAV?$basic_ostream_at_DU?$char_traits_at_D@std@@@std@@_N_at_Z)
referenced in function "protected: __thiscall
boost::archive::text_oarchive_impl<class
boost::archive::text_oarchive>::text_oarchive_impl<class
boost::archive::text_oarchive>(class std::basic_ostream<char,struct
std::char_traits<char> > &,unsigned int)"
(??0?$text_oarchive_impl_at_Vtext_oarchive_at_archive@boost@@@archive_at_boost@@IAE_at_A
AV?$basic_ostream_at_DU?$char_traits_at_D@std@@@std@@I_at_Z)
boost_test.obj : error LNK2019: unresolved external symbol "public:
__thiscall boost::archive::basic_text_iprimitive<class
std::basic_istream<char,struct std::char_traits<char> >
>::basic_text_iprimitive<class std::basic_istream<char,struct
std::char_traits<char> > >(class std::basic_istream<char,struct
std::char_traits<char> > &,bool)"
(??0?$basic_text_iprimitive_at_V?$basic_istream_at_DU?$char_traits_at_D@std@@@std@@@a
rchive_at_boost@@QAE_at_AAV?$basic_istream_at_DU?$char_traits_at_D@std@@@std@@_N_at_Z)
referenced in function "public: __thiscall
boost::archive::text_iarchive_impl<class
boost::archive::text_iarchive>::text_iarchive_impl<class
boost::archive::text_iarchive>(class std::basic_istream<char,struct
std::char_traits<char> > &,unsigned int)"
(??0?$text_iarchive_impl_at_Vtext_iarchive_at_archive@boost@@@archive_at_boost@@QAE_at_A
AV?$basic_istream_at_DU?$char_traits_at_D@std@@@std@@I_at_Z)
Release/boost_test.exe : fatal error LNK1120: 17 unresolved externals
Build Time 0:01
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