Zaphoyd's broadcast_server.cpp
looks like the perfect backbone for a websocket server that it can quickly accept and send messages & connections with a thread for the real action so not to interrupt the communications. https://github.com/zaphoyd/websocketpp/blob/experimental/examples/broadcast_server/broadcast_server.cpp
His simple print_server.cpp
example compiles easily; however, I'm getting a few compile errors with broadcast_server.cpp
.
root@server:~# g++ -O3 broadcast_server.cpp -I ~/websocketpp-experimental/ -lboost_system
broadcast_server.cpp:126:37: error: 'owner_less' is not a member of 'std'
broadcast_server.cpp:126:37: error: 'owner_less' is not a member of 'std'
broadcast_server.cpp:126:70: error: 'con_list' was not declared in this scope
broadcast_server.cpp:126:70: error: template argument 2 is invalid
broadcast_server.cpp:126:18: warning: 'typedef' was ignored in this declaration [enabled by default]
broadcast_server.cpp:129:5: error: 'con_list' does not name a type
broadcast_server.cpp: In member function 'void broadcast_server::process_messages()':
broadcast_server.cpp:109:17: error: 'm_connections' was not declared in this scope
broadcast_server.cpp:112:17: error: 'm_connections' was not declared in this scope
broadcast_server.cpp:116:17: error: 'con_list' has not been declared
broadcast_server.cpp:116:36: error: expected ';' before 'it'
broadcast_server.cpp:117:22: error: 'it' was not declared in this scope
broadcast_server.cpp:117:27: error: 'm_connections' was not declared in this scope
I'm new to c++, and these are probably simple issues, but I can't find my way through them.
'owner_less' is not a member of 'std'
? http://en.cppreference.com/w/cpp/memory/owner_less
I'm guessing that the template argument 2
error
will go away when the above is solved.
'con_list' was not declared in this scope
when it's right there in the private:
? same with 'm_connections'
?
I'm guessing that 'con_list' has not been declared
will go away when the above error does.
I don't know which 'it'
it's talking about or why it should have a ;
in front of it.
versions
Ubuntu 12.10
gcc --version
gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2
boost 1.53.0
extra #include
s
#include <cstdlib>
#include <iostream>
#include <memory>
#include <set>
still nothing
-std=c++11
In file included from /usr/include/c++/4.7/map:60:0,
from /usr/local/include/boost/date_time/gregorian/greg_month.hpp:18,
from /usr/local/include/boost/date_time/gregorian/greg_ymd.hpp:16,
from /usr/local/include/boost/date_time/gregorian/greg_calendar.hpp:16,
from /usr/local/include/boost/date_time/gregorian/gregorian_types.hpp:19,
from /usr/local/include/boost/date_time/posix_time/posix_time_config.hpp:18,
from /usr/local/include/boost/date_time/posix_time/posix_time_system.hpp:13,
from /usr/local/include/boost/date_time/posix_time/ptime.hpp:12,
from /usr/local/include/boost/date_time/posix_time/posix_time_types.hpp:12,
from /usr/local/include/boost/thread/thread_time.hpp:11,
from /usr/local/include/boost/thread/lock_types.hpp:18,
from /usr/local/include/boost/thread/pthread/thread_data.hpp:12,
from /usr/local/include/boost/thread/thread.hpp:17,
from /usr/local/include/boost/thread.hpp:13,
from /root/websocketpp-experimental/websocketpp/common/thread.hpp:41,
from /root/websocketpp-experimental/websocketpp/concurrency/basic.hpp:31,
from /root/websocketpp-experimental/websocketpp/config/core.hpp:35,
from /root/websocketpp-experimental/websocketpp/config/asio_no_tls.hpp:31,
from broadcast_server.cpp:1:
/usr/include/c++/4.7/bits/stl_tree.h: In instantiation of 'class std::_Rb_tree<boost::weak_ptr<void>, boost::weak_ptr<void>, std::_Identity<boost::weak_ptr<void> >, std::owner_less<boost::weak_ptr<void> >, std::allocator<boost::weak_ptr<void> > >':
/usr/include/c++/4.7/bits/stl_set.h:116:17: required from 'class std::set<boost::weak_ptr<void>, std::owner_less<boost::weak_ptr<void> > >'
broadcast_server.cpp:132:14: required from here
/usr/include/c++/4.7/bits/stl_tree.h:471:31: error: invalid use of incomplete type 'struct std::owner_less<boost::weak_ptr<void> >'
In file included from /usr/include/c++/4.7/bits/shared_ptr.h:52:0,
from /usr/include/c++/4.7/memory:87,
from /usr/local/include/boost/config/no_tr1/memory.hpp:21,
from /usr/local/include/boost/smart_ptr/shared_ptr.hpp:27,
from /usr/local/include/boost/shared_ptr.hpp:17,
from /usr/local/include/boost/date_time/time_clock.hpp:17,
from /usr/local/include/boost/thread/thread_time.hpp:9,
from /usr/local/include/boost/thread/lock_types.hpp:18,
from /usr/local/include/boost/thread/pthread/thread_data.hpp:12,
from /usr/local/include/boost/thread/thread.hpp:17,
from /usr/local/include/boost/thread.hpp:13,
from /root/websocketpp-experimental/websocketpp/common/thread.hpp:41,
from /root/websocketpp-experimental/websocketpp/concurrency/basic.hpp:31,
from /root/websocketpp-experimental/websocketpp/config/core.hpp:35,
from /root/websocketpp-experimental/websocketpp/config/asio_no_tls.hpp:31,
from broadcast_server.cpp:1:
/usr/include/c++/4.7/bits/shared_ptr_base.h:270:12: error: declaration of 'struct std::owner_less<boost::weak_ptr<void> >'
how i installed (dependencies, actual program, etc)
https://github.com/zaphoyd/websocketpp/wiki/Setup-0.3X-on-Ubuntu-12.10
alternatives welcome
If anyone has alternatives to std::owner_less
, please post them.