开发者

How to use Boost.Asio on Visual Studio 2005 - Windows Xp?

I have to use the library Boost.asio in C + + Visual Studio 2005 (Windows XP).

I followed these steps: - I downloaded the executable file. exe to install the Boost libraries on Windows XP in my file path.

  • I set the environment variable INCLUDE : W:\boost_1_46_1 (my path file where there are the libraries)

  • in Visual Studio 2005 in the properties of my project (VS->tools->Options project&solutions->vcc++directories) I added $ (INCLUDE)

  • in the properties of my project in visual studio, I added the path of my libraries to the linker to compile my example.

  • I tried to compile the sample files: http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/example/multicast/sender.cpp

  • I have several errors at compilation time:

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

Error 5 error C2143: syntax error : missing ')' before '&' c:\Documents and Settings\GG\Desktop\sender.cpp 24

Error 6 error C2143: syntax error : missing ';' before '&' c:\Documents and Settings\GG\Desktop\sender.cpp 24

Error 7 error C2460: 'sender::io_service' : uses 'sender', which is being defined c:\Documents and Settings\GG\Desktop\sender.cpp 24

Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\Documents and Settings\GG\Desktop\sender.cpp 24

Error 9 error C2653: 'asio' : is not a class or namespace name c:\Documents and Settings\GG\Desktop\sender.cpp 24

Error 10 error C2143: syntax error : missing ';' before '&' c:\D开发者_JAVA百科ocuments and Settings\GG\Desktop\sender.cpp 24

Error 11 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\Documents and Settings\GG\Desktop\sender.cpp 24

Error 13 error C2059: syntax error : ')' c:\Documents and Settings\GG\Desktop\sender.cpp 24

Error 14 error C2065: 'multicast_address' : undeclared identifier c:\Documents and Settings\GG\Desktop\sender.cpp 26

Error 15 error C3861: 'endpoint_': identifier not found c:\Documents and Settings\GG\Desktop\sender.cpp 26

Error 16 error C2531: 'sender::multicast_address' : reference to a bit field illegal c:\Documents and Settings\GG\Desktop\sender.cpp 26

Error 17 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\Documents and Settings\GG\Desktop\sender.cpp 26

Error 18 error C2327: 'sender::io_service' : is not a type name, static, or enumerator c:\Documents and Settings\GG\Desktop\sender.cpp 27

Error 19 error C2061: syntax error : identifier 'io_service' c:\Documents and Settings\GG\Desktop\sender.cpp 27

Error 20 error C2059: syntax error : ')' c:\Documents and Settings\GG\Desktop\sender.cpp 27

Error 21 error C2061: syntax error : identifier 'timer_' c:\Documents and Settings\GG\Desktop\sender.cpp 28

Error 22 error C2143: syntax error : missing ')' before '{' c:\Documents and Settings\GG\Desktop\sender.cpp 30

Error 23 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\Documents and Settings\GG\Desktop\sender.cpp 30

Error 24 error C2143: syntax error : missing ';' before '{' c:\Documents and Settings\GG\Desktop\sender.cpp 39

Error 25 error C2334: unexpected token(s) preceding '{'; skipping apparent function body c:\Documents and Settings\GG\Desktop\sender.cpp 39

Error 26 fatal error C1004: unexpected end-of-file found c:\Documents and Settings\GG\Desktop\sender.cpp 100

I miss some step? Thanks


Now, i have added in the sample file sender.cpp this:

#using namespace boost;

now the errors are reduced as follows:

Error 3 error C2039: 'error_code' : is not a member of 'boost::asio' c:\Documents and Settings\GG\Desktop\sender.cpp 42

Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\Documents and Settings\GG\Desktop\sender.cpp 42

Error 5 error C2143: syntax error : missing ',' before '&' c:\Documents and Settings\GG\Desktop\sender.cpp 42

Error 6 error C2039: 'error_code' : is not a member of 'boost::asio' c:\Documents and Settings\GG\Desktop\sender.cpp 53

Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\Documents and Settings\GG\Desktop\sender.cpp 53

Error 8 error C2143: syntax error : missing ',' before '&' c:\Documents and Settings\GG\Desktop\sender.cpp 53

Error 9 error C2065: 'error' : undeclared identifier c:\Documents and Settings\GG\Desktop\sender.cpp 44


It sounds like you've completed all the steps.

If you right click the #include in VS, and open the include, does it find and open the asio header file? That would be the first indication whether your VS environment is setup correctly.

I would also check if boost has installed correctly: if you selected W:\boost_1_46_1 as the installation directory (this usually defaults to something like C:\Program Files\boost), check that

  • the directory contains a boost folder, which contains the header files as well as library specific folders.
  • the lib directory contains all the built binaries for you version of VS (i.e. vc8 )
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜