我想知道是否可以编译此处找到的 boost 聊天客户端示例(带有 3 个文件的示例:chat_message.hpp、chat_client.cpp 和 chat_server.cpp):
http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/examples.html
使用 VS 2008 编译器?它与 2012 一起编译,但不是 2008 或 2010。我使用的是 boost 版本 1_51
我在 VS 2012 中编译它,但使用 VS 2008 的平台工具集。当我将编译器更改为 2008 时,名称空间行(在 chat_client.cpp 中)突然被智能感知用红色下划线:
using boost::asio::ip::tcp;
我无法弄清楚导致 2008 编译器失败的原因以及是否有某种方法可以解决这个问题(也许使用旧版本的 boost?)。
这是我使用 2008 编译时得到的输出(使用 #define BOOST_LIB_DIAGNOSTIC):
1> Linking to lib file: libboost_system-vc90-mt-1_51.lib
1> Linking to lib file: libboost_date_time-vc90-mt-1_51.lib
1> Linking to lib file: libboost_regex-vc90-mt-1_51.lib
1> Linking to lib file: libboost_thread-vc90-mt-1_51.lib
1> Linking to lib file: libboost_chrono-vc90-mt-1_51.lib
1>c:\users\dustin\documents\boostexamples\boostchatclientexample\chat_message.hpp(70): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\string.h(144) : see declaration of 'strncat'
1>c:\users\dustin\documents\boostexamples\boostchatclientexample\chat_message.hpp(84): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(366) : see declaration of 'sprintf'
1>chat_client.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)
1>chat_client.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ)
1>chat_client.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::thread::detach(void)" (?detach@thread@boost@@QAEXXZ)
1>chat_client.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::thread::join(void)" (?join@thread@boost@@QAEXXZ)
1>chat_client.obj : error LNK2001: unresolved external symbol "private: void __thiscall boost::thread::start_thread(void)" (?start_thread@thread@boost@@AAEXXZ)
1>C:\Users\dustin\Documents\BoostExamples\BoostChatClientExample\Release\BoostChatClientExample.exe : fatal error LNK1120: 5 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========