c++ Boost Visual Studio 10编译错误

C++ Boost Visual Studio 10 Compile error

本文关键字:编译 错误 Studio Boost Visual c++      更新时间:2023-10-16

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

我遵循这个链接来安装boost:如何在Visual Studio 2010中使用boost

现在我得到这个错误,当我点击编译。这是什么原因呢?

我已经包含头文件

#include <boost/thread.hpp>

我只使用线程,互斥锁和条件变量的boost部分。当我试图编译程序时,我得到了这个错误。

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:WorkspaceSrihareDynamicMatrixProblem5DebugProblem5.exe : fatal error LNK1120: 18 unresolved externals
1>
1>Build FAILED.

错误是什么?我已经确保库和头包含在项目的属性

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