【发布时间】:2011-04-20 10:59:42
【问题描述】:
我必须在 C++ Visual Studio 2005 (Windows XP) 中使用库 Boost.asio。
我按照以下步骤操作: - 我下载了可执行文件。 exe 在我的文件路径中安装 Windows XP 上的 Boost 库。
我设置了环境变量 INCLUDE : W:\boost_1_46_1(我的路径文件所在的库)
在 Visual Studio 2005 的项目属性中(VS->tools->Options project&solutions->vcc++directories)我添加了 $ (INCLUDE)
在 Visual Studio 项目的属性中,我将库的路径添加到链接器以编译我的示例。
我尝试编译示例文件:http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/example/multicast/sender.cpp
我在编译时有几个错误:
Error 3 error C2653: 'asio' : is not a class or namespace name c:\Documents and Settings\GG\Desktop\sender.cpp 2
Error 4 error C2653: 'asio' : is not a class or namespace name c:\Documents and Settings\GG\Desktop\sender.cpp 24
错误 5 错误 C2143:语法错误:在 '&' 之前缺少 ')' c:\Documents and Settings\GG\Desktop\sender.cpp 24
错误 6 错误 C2143:语法错误:缺少 ';'在'&'之前 c:\Documents and Settings\GG\Desktop\sender.cpp 24
错误 7 错误 C2460: 'sender::io_service' : 使用 'sender',正在定义 c:\Documents and Settings\GG\Desktop\sender.cpp 24
错误 8 错误 C4430:缺少类型说明符 - 假定为 int。注意:C++ 不支持 default-int c:\Documents and Settings\GG\Desktop\sender.cpp 24
错误 9 错误 C2653: 'asio' : 不是类或命名空间名称 c:\Documents and Settings\GG\Desktop\sender.cpp 24
错误 10 错误 C2143:语法错误:缺少 ';'在'&'之前 c:\Documents and Settings\GG\Desktop\sender.cpp 24
错误 11 错误 C4430:缺少类型说明符 - 假定为 int。注意:C++ 不支持 default-int c:\Documents and Settings\GG\Desktop\sender.cpp 24
错误 13 错误 C2059:语法错误:')' c:\Documents and Settings\GG\Desktop\sender.cpp 24
错误 14 错误 C2065:'multicast_address':未声明的标识符 c:\Documents and Settings\GG\Desktop\sender.cpp 26
错误 15 错误 C3861: 'endpoint_': identifier not found c:\Documents and Settings\GG\Desktop\sender.cpp 26
错误 16 错误 C2531: 'sender::multicast_address' : 引用位字段非法 c:\Documents and Settings\GG\Desktop\sender.cpp 26
错误 17 错误 C4430:缺少类型说明符 - 假定为 int。注意:C++ 不支持 default-int c:\Documents and Settings\GG\Desktop\sender.cpp 26
错误 18 错误 C2327: 'sender::io_service' : 不是类型名称、静态或枚举器 c:\Documents and Settings\GG\Desktop\sender.cpp 27
错误 19 错误 C2061:语法错误:标识符 'io_service' c:\Documents and Settings\GG\Desktop\sender.cpp 27
错误 20 错误 C2059:语法错误:')' c:\Documents and Settings\GG\Desktop\sender.cpp 27
错误 21 错误 C2061:语法错误:标识符 'timer_' c:\Documents and Settings\GG\Desktop\sender.cpp 28
错误 22 错误 C2143:语法错误:在 '{' c:\Documents and Settings\GG\Desktop\sender.cpp 30 之前缺少 ')'
错误 23 错误 C4430:缺少类型说明符 - 假定为 int。注意:C++ 不支持 default-int c:\Documents and Settings\GG\Desktop\sender.cpp 30
错误 24 错误 C2143:语法错误:缺少 ';'在'{'之前 c:\Documents and Settings\GG\Desktop\sender.cpp 39
错误 25 错误 C2334:'{' 前面的意外标记;跳过明显的函数体 c:\Documents and Settings\GG\Desktop\sender.cpp 39
错误 26 致命错误 C1004:发现意外的文件结尾 c:\Documents and Settings\GG\Desktop\sender.cpp 100
我错过了一些步骤? 谢谢
现在,我在示例文件 sender.cpp 中添加了这个:
#using namespace boost;
现在错误减少如下:
错误 3 错误 C2039: 'error_code' : is not a member of 'boost::asio' c:\Documents and Settings\GG\Desktop\sender.cpp 42
错误 4 错误 C4430:缺少类型说明符 - 假定为 int。注意:C++ 不支持 default-int c:\Documents and Settings\GG\Desktop\sender.cpp 42
错误 5 错误 C2143:语法错误:在 '&' 之前缺少 ',' c:\Documents and Settings\GG\Desktop\sender.cpp 42
错误 6 错误 C2039: 'error_code' : is not a member of 'boost::asio' c:\Documents and Settings\GG\Desktop\sender.cpp 53
错误 7 错误 C4430:缺少类型说明符 - 假定为 int。注意:C++ 不支持 default-int c:\Documents and Settings\GG\Desktop\sender.cpp 53
错误 8 错误 C2143:语法错误:在 '&' 之前缺少 ',' c:\Documents and Settings\GG\Desktop\sender.cpp 53
错误 9 错误 C2065: 'error' : undeclared identifier c:\Documents and Settings\GG\Desktop\sender.cpp 44
【问题讨论】:
标签: c++ visual-studio-2005 windows-xp boost-asio