如何在Visual Studio 2005上使用Boost.Asio - Windows Xp?

时间:2011-04-20 10:59:42

标签: c++ visual-studio-2005 windows-xp boost-asio

我必须在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 ++目录)我添加了$(INCLUDE)

  • 在visual studio的项目属性中,我将我的库的路径添加到链接器以编译我的示例。

  • 我尝试编译示例文件:http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/example/multicast/sender.cpp

  • 我在编译时遇到了几个错误:

错误3错误C2653:'asio':不是类或命名空间名称c:\ Documents and Settings \ GG \ Desktop \ sender.cpp 2

错误4错误C2653:'asio':不是类或命名空间名称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_':找不到标识符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':不是'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':不是'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:'错误':未声明的标识符c:\ Documents and Settings \ GG \ Desktop \ sender.cpp 44

1 个答案:

答案 0 :(得分:0)

听起来你已经完成了所有步骤。

如果右键单击VS中的 #include ,然后打开include,它是否会找到并打开asio头文件?这将是您的VS环境是否正确设置的第一个指示。

我还会检查boost是否已正确安装:如果您选择W:\ boost_1_46_1作为安装目录(这通常默认为C:\ Program Files \ boost),请检查

  • 该目录包含 boost 文件夹,其中包含头文件以及库特定文件夹。
  • lib目录包含VS版本的所有内置二进制文件(即vc8)
相关问题