错误:“信号集”在命名空间“boost::asio”中没有命名类型
我正在开发 Boost::asio 库 v1.47 的第一个 HTTP 服务器示例。 http://www.boost.org/doc/ libs/1_47_0/doc/html/boost_asio/examples.html
我在使用 gcc 版本 4.5.2 编译时收到此消息:
错误:命名空间“boost::asio”中的“signal_set”未命名类型
我使用 Jam 的类型,使用此 jamfile :
C++ = g++ ;
LINK = $(C++) ;
LINKLIBS = -lboost_system-mt -lboost_filesystem-mt ;
Main node : main.cpp server.cpp reply.cpp request_handler.cpp request_parser.cpp connection.cpp connection_manager.cpp ;
我认为代码是正确的,因为我从一开始就遇到了错误,没有修改示例源代码,我只是评论了之前解决问题的线路。 但现在,我需要信号。
所以我想我的 Jamfile 搞砸了。
我发现另一个与我相关的问题,但它对我没有帮助: 尝试使用 boost::asio::signal_set 时无法编译
编辑: 事实上我发现: 我使用的 Ubuntu 仅提供 1.42 版本的 boost,并且 boost::asio::signals 尚未实现...... 我安装了最新版本,现在一切正常。
I'm working on the first HTTP server example of the Boost::asio library v1.47.
http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/examples.html
And I got this message at compilation with gcc version 4.5.2 :
error: ‘signal_set’ in namespace ‘boost::asio’ does not name a type
I use Jam, with this jamfile :
C++ = g++ ;
LINK = $(C++) ;
LINKLIBS = -lboost_system-mt -lboost_filesystem-mt ;
Main node : main.cpp server.cpp reply.cpp request_handler.cpp request_parser.cpp connection.cpp connection_manager.cpp ;
I think the code is correct because I got the error from the beginning, without modifying the example source, I just commented the line to resolve the problem previously.
But now, I need signals.
So I think I messed something up with my Jamfile.
I found this other question related to mine, bt it didn't helped me :
Cannot compile when trying to utilize boost::asio::signal_set
Edit :
In fact I figured out :
Ubuntu which I am using provide only the version 1.42 of boost, and boost::asio::signals wern't implemented yet ...
I installed the latest version, and now everything is fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误告诉您编译器无法识别该标识符。当您忘记包含标头,或者标头的版本不同且不包含该标识符时,这是一种常见情况。
这是编译器产生的第一个错误吗?特别是,它是否抱怨无法找到任何标头?这可能表明标头不在编译器正在检查的路径中,在这种情况下,您可能需要向编译行添加
-Ipath_to_boost
标志。如果您可以生成遇到该错误时正在编译的实际文件,那也会很有趣。
That error is telling you that the compiler does not recognize the identifier. This is a common situation when you forget to include a header, or if the version of your header is different and does not contain that identifier.
Is that the first error that the compiler is producing? In particular, has it complained that it cannot locate any header? That could indicate that the headers are not in the path that the compiler is checking in which case you might want to add a
-Ipath_to_boost
flag to the compile line.It would also be interesting if you can produce what actual file is being compiled when that error is encountered.