2012-10-17 115 views
2

我在VS2010中使用以下代碼 - 64位和我的增強庫也是64位 我不斷收到這些鏈接錯誤,雖然我已經在鏈接器設置中添加了Boost庫,額外的標題。有關我如何解決此問題的任何建議?鏈接器錯誤與升壓序列

#include <boost/archive/text_oarchive.hpp> 
#include <boost/archive/text_iarchive.hpp> 
#include <iostream> 
#include <sstream> 
std::stringstream ss; 

//-------------------------------------- 
class person 
{ 
public: 
    person() 
    { 
    } 

    person(int age) 
     : age_(age) 
    { 
    } 

    int age() const 
    { 
     return age_; 
    } 

private: 

    friend class boost::serialization::access; 

    template <typename Archive> 
    void serialize(Archive &ar, const unsigned int version) 
    { 
     ar & age_; 
    } 

    int age_; 
}; 
//--------------------------------------- 
int main(int argc, char** argv) 
{ 

    boost::archive::text_oarchive oa(ss); 
    person p(31); 
    oa << p; 
} 

這些都是鏈接錯誤

Error 12 error LNK2001: unresolved external symbol "private: virtual char const * __cdecl boost::serialization::typeid_system::extended_type_info_typeid_0::get_debug_info(void)const " ([email protected][email protected][email protected]@[email protected]@EEBAPEBDXZ) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 22 error LNK2001: unresolved external symbol "public: __cdecl boost::archive::archive_exception::archive_exception(class boost::archive::archive_exception const &)" ([email protected]@[email protected]@[email protected]@@Z) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 11 error LNK2001: unresolved external symbol "public: virtual bool __cdecl boost::serialization::typeid_system::extended_type_info_typeid_0::is_equal(class boost::serialization::extended_type_info const &)const " ([email protected][email protected][email protected]@[email protected]@[email protected]@@Z) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 10 error LNK2001: unresolved external symbol "public: virtual bool __cdecl boost::serialization::typeid_system::extended_type_info_typeid_0::is_less_than(class boost::serialization::extended_type_info const &)const " ([email protected][email protected][email protected]@[email protected]@[email protected]@@Z) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 21 error LNK2001: unresolved external symbol "public: void __cdecl boost::archive::archive_exception::`vbase destructor'(void)" ([email protected]@[email protected]@QEAAXXZ) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: __cdecl 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)" ([email protected][email protected]?$c[email protected]@[email protected]@@[email protected]@@[email protected]@@[email protected]) referenced in function "protected: __cdecl boost::archive::text_oarchive_impl<class boost::archive::text_oarchive>::~text_oarchive_impl<class boost::archive::text_oarchive>(void)" ([email protected][email protected]@[email protected]@@[email protected]@@[email protected]) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 3 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: __cdecl boost::archive::detail::basic_oarchive::~basic_oarchive(void)" ([email protected]@[email protected]@@[email protected]) referenced in function "public: __cdecl boost::archive::detail::common_oarchive<class boost::archive::text_oarchive>::~common_oarchive<class boost::archive::text_oarchive>(void)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]@[email protected]) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 9 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: __cdecl boost::archive::detail::basic_oserializer::~basic_oserializer(void)" ([email protected]@[email protected]@@[email protected]) referenced in function "public: virtual __cdecl boost::archive::detail::oserializer<class boost::archive::text_oarchive,class person>::~oserializer<class boost::archive::text_oarchive,class person>(void)" ([email protected][email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@[email protected]) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 8 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: __cdecl boost::archive::detail::basic_oserializer::basic_oserializer(class boost::serialization::extended_type_info const &)" ([email protected]@[email protected]@@[email protected][email protected]@[email protected]@Z) referenced in function "public: __cdecl boost::archive::detail::oserializer<class boost::archive::text_oarchive,class person>::oserializer<class boost::archive::text_oarchive,class person>(void)" ([email protected][email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@[email protected]) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: __cdecl 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)" ([email protected][email protected]@[email protected]@@[email protected]@@[email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) referenced in function "public: __cdecl boost::archive::text_oarchive::text_oarchive(class std::basic_ostream<char,struct std::char_traits<char> > &,unsigned int)" ([email protected]@[email protected]@[email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 13 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: __cdecl boost::serialization::typeid_system::extended_type_info_typeid_0::~extended_type_info_typeid_0(void)" ([email protected][email protected]@[email protected]@[email protected]) referenced in function "int `public: __cdecl boost::serialization::extended_type_info_typeid<class person>::extended_type_info_typeid<class person>(void)'::`1'::dtor$0" ([email protected][email protected]@@@[email protected]@@[email protected]@4HA) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 16 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: __cdecl boost::serialization::typeid_system::extended_type_info_typeid_0::extended_type_info_typeid_0(char const *)" ([email protected][email protected]@[email protected]@[email protected]@Z) referenced in function "public: __cdecl boost::serialization::extended_type_info_typeid<class person>::extended_type_info_typeid<class person>(void)" ([email protected]@@@[email protected]@@[email protected]) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 6 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: void __cdecl boost::archive::basic_text_oarchive<class boost::archive::text_oarchive>::newtoken(void)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@@IEAAXXZ) referenced in function "protected: void __cdecl boost::archive::text_oarchive_impl<class boost::archive::text_oarchive>::save<class boost::archive::object_id_type>(class boost::archive::object_id_type const &)" ([email protected][email protected]@[email protected]@@[email protected][email protected]@[email protected]@@[email protected]@@[email protected]@@Z) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 19 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: void __cdecl 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 &)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@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 &)" ([email protected][email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 14 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: void __cdecl boost::serialization::extended_type_info::key_register(void)const " ([email protected][email protected]@[email protected]@IEBAXXZ) referenced in function "public: __cdecl boost::serialization::extended_type_info_typeid<class person>::extended_type_info_typeid<class person>(void)" ([email protected]@@@[email protected]@@[email protected]) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 24 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: void __cdecl boost::serialization::extended_type_info::key_unregister(void)const " ([email protected][email protected]@[email protected]@IEBAXXZ) referenced in function "public: __cdecl boost::serialization::extended_type_info_typeid<class person>::~extended_type_info_typeid<class person>(void)" ([email protected]@@@[email protected]@@[email protected]) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 15 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: void __cdecl boost::serialization::typeid_system::extended_type_info_typeid_0::type_register(class type_info const &)" ([email protected][email protected][email protected]@[email protected]@[email protected]@@Z) referenced in function "public: __cdecl boost::serialization::extended_type_info_typeid<class person>::extended_type_info_typeid<class person>(void)" ([email protected]@@@[email protected]@@[email protected]) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 23 error LNK2019: unresolved external symbol "__declspec(dllimport) protected: void __cdecl boost::serialization::typeid_system::extended_type_info_typeid_0::type_unregister(void)" ([email protected][email protected][email protected]@[email protected]@IEAAXXZ) referenced in function "public: __cdecl boost::serialization::extended_type_info_typeid<class person>::~extended_type_info_typeid<class person>(void)" ([email protected]@@@[email protected]@@[email protected]) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 20 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl boost::archive::archive_exception::archive_exception(class boost::archive::archive_exception const &)" ([email protected]@[email protected]@[email protected]@@Z) referenced in function "void __cdecl boost::serialization::throw_exception<class boost::archive::archive_exception>(class boost::archive::archive_exception const &)" ([email protected][email protected]@[email protected]@@[email protected]@@[email protected]@[email protected]@Z) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 18 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl boost::archive::archive_exception::archive_exception(enum boost::archive::archive_exception::_exception_code,char const *,char const *)" ([email protected]@[email protected]@[email protected][email protected]@[email protected]) referenced in function "protected: void __cdecl boost::archive::basic_text_oprimitive<classstd::basic_ostream<char,struct std::char_traits<char> > >::save<class boost::archive::object_id_type>(class boost::archive::object_id_type const &)" ([email protected][email protected]@[email protected]@@[email protected][email protected][email protected]@[email protected]@@[email protected]@@[email protected]@@[email protected]@@Z) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 7 error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __cdecl boost::archive::detail::basic_oserializer::serialized_as_pointer(void)const " ([email protected][email protected]@[email protected]@@QEBA_NXZ) referenced in function "public: virtual bool __cdecl boost::archive::detail::oserializer<class boost::archive::text_oarchive,class person>::tracking(unsigned int)const " ([email protected][email protected][email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@[email protected]) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 17 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl boost::archive::archive_exception::`vbase destructor'(void)" ([email protected]@[email protected]@QEAAXXZ) referenced in function "protected: void __cdecl boost::archive::basic_text_oprimitive<class std::basic_ostream<char,struct std::char_traits<char> > >::save<class boost::archive::object_id_type>(class boost::archive::object_id_type const &)" ([email protected][email protected]@[email protected]@@[email protected][email protected][email protected]@[email protected]@@[email protected]@@[email protected]@@[email protected]@@Z) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 4 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl boost::archive::detail::basic_oarchive::end_preamble(void)" ([email protected][email protected]@[email protected]@@QEAAXXZ) referenced in function "public: static void __cdecl boost::archive::save_access::save_primitive<class boost::archive::text_oarchive,class boost::archive::object_id_type>(classboost::archive::text_oarchive &,class boost::archive::object_id_type const &)" ([email protected][email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected]@@Z) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 
Error 5 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl boost::archive::detail::basic_oarchive::save_object(void const *,class boost::archive::detail::basic_oserializer const &)" ([email protected][email protected]@[email protected]@@[email protected]@@Z) referenced in function "public: static void __cdecl boost::archive::detail::save_non_pointer_type<class boost::archive::text_oarchive>::save_standard::invoke<class person>(class boost::archive::text_oarchive &,class person const &)" ([email protected]@@@[email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected]@@Z) D:\Tproj-0.18\TestProject\QTR\QTR\main.obj QTR 

回答

1

或許你已經被用升壓自動鏈接和您明確指定的庫鏈接庫之間的衝突。

定義值BOOST_ALL_NO_LIB = 1並指定顯式所需的庫。

另一種選擇是使用升壓自動鏈接:從連接選項刪除所有Boost庫,並查找任何缺少庫的輸出(定義BOOST_LIB_DIAGNOSTIC = 1進行更詳細的輸出)

+0

我意識到,我的項目有一個名爲BOOST_ALL_NO_LIB的預處理器,解決了這個問題。我不知道那個預處理器是幹什麼的 – Murphy316