C ++ Boost Visual Studio 10编译错误

时间:2015-05-23 17:48:07

标签: c++ multithreading visual-studio-2010 boost

我使用Windows 7 Premium 64位笔记本电脑使用Boost库编译程序。

我按照此链接进行了加速安装:How to use Boost in Visual Studio 2010

现在,当我点击编译时,我收到此错误。造成这种情况的原因是什么?

我已经包含了头文件

#include <boost/thread.hpp>

我只对boost部分使用thread,mutex和condition_variable。 我在尝试编译程序时收到此错误。

1>  All outputs are up-to-date.
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const & __cdecl boost::system::system_category(void)" (__imp_?system_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "public: __thiscall boost::thread_exception::thread_exception(int,char const *)" (??0thread_exception@boost@@QAE@HPBD@Z)
1>ThreadedFileWriter.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const & __cdecl boost::system::system_category(void)" (__imp_?system_category@system@boost@@YAABVerror_category@12@XZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (__imp_?generic_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'posix_category''(void)" (??__Eposix_category@system@boost@@YAXXZ)
1>ThreadedFileWriter.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (__imp_?generic_category@system@boost@@YAABVerror_category@12@XZ)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::thread::~thread(void)" (__imp_??1thread@boost@@QAE@XZ) referenced in function "public: __thiscall KThreadedFileWriter::KThreadedFileWriter(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (??0KThreadedFileWriter@@QAE@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class boost::thread & __thiscall boost::thread::operator=(class boost::thread &&)" (__imp_??4thread@boost@@QAEAAV01@$$QAV01@@Z) referenced in function "public: __thiscall KThreadedFileWriter::KThreadedFileWriter(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (??0KThreadedFileWriter@@QAE@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::thread::thread(void)" (__imp_??0thread@boost@@QAE@XZ) referenced in function "public: __thiscall KThreadedFileWriter::KThreadedFileWriter(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (??0KThreadedFileWriter@@QAE@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::detail::win32::handle_manager::handle_manager(void *)" (__imp_??0handle_manager@win32@detail@boost@@QAE@PAX@Z) referenced in function "public: __thiscall boost::detail::basic_condition_variable::basic_condition_variable(void)" (??0basic_condition_variable@detail@boost@@QAE@XZ)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::detail::win32::handle_manager::~handle_manager(void)" (__imp_??1handle_manager@win32@detail@boost@@QAE@XZ) referenced in function "public: __thiscall boost::detail::basic_condition_variable::~basic_condition_variable(void)" (??1basic_condition_variable@detail@boost@@QAE@XZ)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class boost::detail::win32::handle_manager & __thiscall boost::detail::win32::handle_manager::operator=(void *)" (__imp_??4handle_manager@win32@detail@boost@@QAEAAV0123@PAX@Z) referenced in function "public: void __thiscall boost::detail::basic_condition_variable::notify_all(void)" (?notify_all@basic_condition_variable@detail@boost@@QAEXXZ)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::detail::win32::handle_manager::operator void *(void)const " (__imp_??Bhandle_manager@win32@detail@boost@@QBEPAXXZ) referenced in function "public: void __thiscall boost::detail::basic_cv_list_entry::release(unsigned int)" (?release@basic_cv_list_entry@detail@boost@@QAEXI@Z)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: void __thiscall boost::thread::start_thread(void)" (__imp_?start_thread@thread@boost@@AAEXXZ) referenced in function "public: __thiscall boost::thread::thread<void (__thiscall KThreadedFileWriter::*)(void),class KThreadedFileWriter *>(void (__thiscall KThreadedFileWriter::*)(void),class KThreadedFileWriter *,struct boost::thread::dummy *)" (??$?0P8KThreadedFileWriter@@AEXXZPAV0@@thread@boost@@QAE@P8KThreadedFileWriter@@AEXXZPAV2@PAUdummy@01@@Z)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::gregorian::greg_month::greg_month(unsigned short)" (__imp_??0greg_month@gregorian@boost@@QAE@G@Z) referenced in function "public: __thiscall boost::gregorian::date::date(enum boost::date_time::special_values)" (??0date@gregorian@boost@@QAE@W4special_values@date_time@2@@Z)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::gregorian::greg_month::operator unsigned short(void)const " (__imp_??Bgreg_month@gregorian@boost@@QBEGXZ) referenced in function "public: static unsigned int __cdecl boost::date_time::gregorian_calendar_base<struct boost::date_time::year_month_day_base<class boost::gregorian::greg_year,class boost::gregorian::greg_month,class boost::gregorian::greg_day>,unsigned int>::day_number(struct boost::date_time::year_month_day_base<class boost::gregorian::greg_year,class boost::gregorian::greg_month,class boost::gregorian::greg_day> const &)" (?day_number@?$gregorian_calendar_base@U?$year_month_day_base@Vgreg_year@gregorian@boost@@Vgreg_month@23@Vgreg_day@23@@date_time@boost@@I@date_time@boost@@SAIABU?$year_month_day_base@Vgreg_year@gregorian@boost@@Vgreg_month@23@Vgreg_day@23@@23@@Z)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) bool __cdecl boost::this_thread::interruptible_wait(void *,struct boost::detail::timeout)" (__imp_?interruptible_wait@this_thread@boost@@YA_NPAXUtimeout@detail@2@@Z) referenced in function "public: bool __thiscall boost::detail::basic_cv_list_entry::wait(struct boost::detail::timeout)" (?wait@basic_cv_list_entry@detail@boost@@QAE_NUtimeout@23@@Z)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall boost::detail::win32::handle_manager::operator!(void)const " (__imp_??7handle_manager@win32@detail@boost@@QBE_NXZ) referenced in function "private: class boost::intrusive_ptr<class boost::detail::basic_cv_list_entry> __thiscall boost::detail::basic_condition_variable::get_wait_entry(void)" (?get_wait_entry@basic_condition_variable@detail@boost@@AAE?AV?$intrusive_ptr@Vbasic_cv_list_entry@detail@boost@@@3@XZ)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void * __thiscall boost::detail::win32::handle_manager::duplicate(void)const " (__imp_?duplicate@handle_manager@win32@detail@boost@@QBEPAXXZ) referenced in function "public: __thiscall boost::detail::basic_cv_list_entry::basic_cv_list_entry(class boost::detail::win32::handle_manager const &)" (??0basic_cv_list_entry@detail@boost@@QAE@ABVhandle_manager@win32@12@@Z)
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall boost::detail::thread_data_base::~thread_data_base(void)" (__imp_??1thread_data_base@detail@boost@@UAE@XZ) referenced in function __unwindfunclet$??0?$thread_data@V?$bind_t@XV?$mf0@XVKThreadedFileWriter@@@_mfi@boost@@V?$list1@V?$value@PAVKThreadedFileWriter@@@_bi@boost@@@_bi@3@@_bi@boost@@@detail@boost@@QAE@$$QAV?$bind_t@XV?$mf0@XVKThreadedFileWriter@@@_mfi@boost@@V?$list1@V?$value@PAVKThreadedFileWriter@@@_bi@boost@@@_bi@3@@_bi@2@@Z$0
1>ThreadedFileWriter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::detail::thread_data_base::thread_data_base(void)" (__imp_??0thread_data_base@detail@boost@@QAE@XZ) referenced in function "public: __thiscall boost::detail::thread_data<class boost::_bi::bind_t<void,class boost::_mfi::mf0<void,class KThreadedFileWriter>,class boost::_bi::list1<classboost::_bi::value<class KThreadedFileWriter *> > > >::thread_data<class boost::_bi::bind_t<void,class boost::_mfi::mf0<void,class KThreadedFileWriter>,class boost::_bi::list1<class boost::_bi::value<class KThreadedFileWriter *> > > >(class boost::_bi::bind_t<void,class boost::_mfi::mf0<void,class KThreadedFileWriter>,class boost::_bi::list1<class boost::_bi::value<class KThreadedFileWriter *> > > &&)" (??0?$thread_data@V?$bind_t@XV?$mf0@XVKThreadedFileWriter@@@_mfi@boost@@V?$list1@V?$value@PAVKThreadedFileWriter@@@_bi@boost@@@_bi@3@@_bi@boost@@@detail@boost@@QAE@$$QAV?$bind_t@XV?$mf0@XVKThreadedFileWriter@@@_mfi@boost@@V?$list1@V?$value@PAVKThreadedFileWriter@@@_bi@boost@@@_bi@3@@_bi@2@@Z)
1>ThreadedFileWriter.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall boost::detail::thread_data_base::notify_all_at_thread_exit(class boost::condition_variable *,class boost::mutex *)" (?notify_all_at_thread_exit@thread_data_base@detail@boost@@UAEXPAVcondition_variable@3@PAVmutex@3@@Z)
1>E:\WorkspaceSrihare\DynamicMatrix\Problem5\Debug\Problem5.exe : fatal error LNK1120: 18 unresolved externals
1>
1>Build FAILED.

错误是什么。我确保lib和header包含在项目的属性中。

1 个答案:

答案 0 :(得分:1)

您需要将二进制文件链接到项目,转到项目的属性,链接器,常规,并将地址提供给您编译为boost的二进制文件夹(默认情况下,它位于boost的根文件夹中的stage目录中) )。如果这不起作用,请尝试将完整地址添加到与项目属性,链接器,输入,附加依赖项中的线程相关的lib文件中。