我是c ++的新手,甚至更新。刚刚安装并将boost连接到Code :: Blocks后,我运行了一个示例代码,它似乎工作正常。
我开始浏览boost::asio tutorial。我真的试图复制并粘贴他们的代码,构建并运行它,但仍然会出错......
D:\Downloads\boost_1_55_0\boost\asio\detail\config.hpp|486|warning: #warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. [-Wcpp]|
D:\Downloads\boost_1_55_0\boost\asio\detail\config.hpp|487|warning: #warning For example, add -D_WIN32_WINNT=0x0501 to the compiler command line. [-Wcpp]|
D:\Downloads\boost_1_55_0\boost\asio\detail\config.hpp|488|warning: #warning Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target). [-Wcpp]|
obj\Debug\main.o||In function `_static_initialization_and_destruction_0':|
D:\Downloads\boost_1_55_0\boost\system\error_code.hpp|222|undefined reference to `boost::system::generic_category()'|
D:\Downloads\boost_1_55_0\boost\system\error_code.hpp|223|undefined reference to `boost::system::generic_category()'|
D:\Downloads\boost_1_55_0\boost\system\error_code.hpp|224|undefined reference to `boost::system::system_category()'|
obj\Debug\main.o||In function `ZN5boost6system10error_codeC1Ev':|
D:\Downloads\boost_1_55_0\boost\system\error_code.hpp|323|undefined reference to `boost::system::system_category()'|
obj\Debug\main.o||In function `ZN5boost4asio5error19get_system_categoryEv':|
D:\Downloads\boost_1_55_0\boost\asio\error.hpp|224|undefined reference to `boost::system::system_category()'|
obj\Debug\main.o||In function `ZN5boost4asio6detail17winsock_init_base7startupERNS2_4dataEhh':|
D:\Downloads\boost_1_55_0\boost\asio\detail\impl\winsock_init.ipp|39|undefined reference to `WSAStartup@8'|
obj\Debug\main.o||In function `ZN5boost4asio6detail17winsock_init_base7cleanupERNS2_4dataE':|
D:\Downloads\boost_1_55_0\boost\asio\detail\impl\winsock_init.ipp|56|undefined reference to `WSACleanup@0'|
obj\Debug\main.o||In function `ZN5boost4asio6detail10socket_ops16clear_last_errorEv':|
D:\Downloads\boost_1_55_0\boost\asio\detail\impl\socket_ops.ipp|69|undefined reference to `WSASetLastError@4'|
obj\Debug\main.o||In function `ZN5boost4asio6detail10socket_ops6selectEiP6fd_setS4_S4_P7timevalRNS_6system10error_codeE':|
D:\Downloads\boost_1_55_0\boost\asio\detail\impl\socket_ops.ipp|1742|undefined reference to `select@20'|
obj\Debug\main.o||In function `ZN5boost4asio6detail10socket_ops13error_wrapperIiEET_S4_RNS_6system10error_codeE':|
D:\Downloads\boost_1_55_0\boost\asio\detail\impl\socket_ops.ipp|82|undefined reference to `WSAGetLastError@0'|
||=== Build finished: 10 errors, 3 warnings (0 minutes, 3 seconds) ===|
答案 0 :(得分:1)
对于Eclipse,添加符号:_WIN32_WINNT val:0x0601(或对于您的Windows系统:http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745%28v=vs.85%29.aspx)以解决您引用的前3行中的主要问题。我不使用代码块,但我想这个过程是类似的。
还要将BOOST_ROOT / stage / lib添加到库包含路径,并包含特定的boost_system- 任何库。