Zaphoydbroadcast_server.cpp
看起来像是 websocket 服务器的完美主干,它可以快速接受和发送消息以及与线程的连接以进行实际操作,因此不会中断通信。 https://github.com/zaphoyd/websocketpp/blob/experimental/examples/broadcast_server/broadcast_server.cpp
他的简单print_server.cpp
示例很容易编译;但是,我遇到了一些编译错误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
我是 C++ 新手,这些可能是简单的问题,但我找不到解决方法。
'owner_less' is not a member of 'std'
? http://en.cppreference.com/w/cpp/memory/owner_less
我猜template argument 2
error
当上述问题解决后,它就会消失。
'con_list' was not declared in this scope
什么时候在里面private:
?与'm_connections'
?
我猜'con_list' has not been declared
当上述错误发生时,它会消失。
我不知道它在说什么,也不知道为什么它前面'it'
应该有一个。;
版本
Ubuntu 12.10
gcc --version
gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2
提升 1.53.0
额外#include
的
#include <cstdlib>
#include <iostream>
#include <memory>
#include <set>
依然没有
-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> >'
我是如何安装的(依赖项、实际程序等)
https://github.com/zaphoyd/websocketpp/wiki/Setup-0.3X-on-Ubuntu-12.10
欢迎替代品
如果有人有替代品std::owner_less
,请张贴。