I'm trying to use boost.asio to implement a multicast sender. I have a my thread implementation and I need my boost.asio only for management of the socket.
I looked at the example on the site of boost but I did not understand and I do not Compile. Where can I find what I need?
The complile errors are: (I have tried this example: 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
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:\Documents 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 er开发者_如何转开发ror 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
The example you have chosen to compile should build cleanly assuming you have boost installed correctly. I don't know how your development environment is setup. On my system I have boost installed in /opt/local
so the headers are in /opt/local/include
and the libraries to link against are in /opt/local/lib
. My compile and link line looks like
stackoverflow samm$ g++ sender.cpp -I /opt/local/include/ -L/opt/local/lib -lboost_system -Wl,-rpath,/opt/local/lib
The first error you see
Error 3 error C2653: 'asio' : is not a class or namespace name c:\Documents and Settings\GG\Desktop\sender.cpp 2
looks like you forgot to #include <boost/asio.hpp>
somewhere. But I am far from a Windows development expert, so perhaps someone more knowledgeable will answer.
精彩评论