Error in websocketpp library and boost in windows Visual Studio 2015 [closed]

邮差的信 提交于 2019-12-08 07:44:51

问题


I'm trying to compile this simple example https://github.com/zaphoyd/websocketpp/blob/master/examples/echo_server/echo_server.cpp from the developer github, but I'm getting strange errors outside the code.

I have also tried turning on the /Za option as shown in this post: VC++ 2012 and Boost incompatibility - `throw()` specifications in library headers but it throws a different error, saying "Threading support unavaliable: it has been explicitly disabled with BOOST_DISABLE_THREADS"

Does someone know how to fix this? thanks!

The errors: I'm using Visual Studio 2015 in Windows10 x64, C:\websocketpp\websocketpp/transport/base/connection.hpp(187): error C2694: 'const char *websocketpp::transport::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const' 1> C:\websocketpp\websocketpp/transport/base/connection.hpp(187): note: see declaration of 'websocketpp::transport::error::category::name' 1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name' 1>C:\websocketpp\websocketpp/transport/iostream/base.hpp(89): error C2694: 'const char *websocketpp::transport::iostream::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const' 1> C:\websocketpp\websocketpp/transport/iostream/base.hpp(89): note: see declaration of 'websocketpp::transport::iostream::error::category::name' 1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name' 1>C:\websocketpp\websocketpp/error.hpp(151): error C2694: 'const char *websocketpp::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const' 1> C:\websocketpp\websocketpp/error.hpp(151): note: see declaration of 'websocketpp::error::category::name' 1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name' 1>C:\websocketpp\websocketpp/frame.hpp(831): warning C4267: '=': conversion from 'size_t' to 'uint32_t', possible loss of data 1>C:\websocketpp\websocketpp/extensions/extension.hpp(65): error C2694: 'const char *websocketpp::extensions::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const' 1> C:\websocketpp\websocketpp/extensions/extension.hpp(65): note: see declaration of 'websocketpp::extensions::error::category::name' 1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name' 1>C:\local\boost_1_59_0\boost/asio/detail/config.hpp(227): warning C4005: 'BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT': macro redefinition 1> C:\local\boost_1_59_0\boost/asio/detail/config.hpp(213): note: see previous definition of 'BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT' 1>C:\websocketpp\websocketpp/transport/asio/base.hpp(189): error C2694: 'const char *websocketpp::transport::asio::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const' 1> C:\websocketpp\websocketpp/transport/asio/base.hpp(189): note: see declaration of 'websocketpp::transport::asio::error::category::name' 1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name' 1>C:\websocketpp\websocketpp/transport/asio/security/base.hpp(109): error C2694: 'const char *websocketpp::transport::asio::socket::socket_category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const' 1> C:\websocketpp\websocketpp/transport/asio/security/base.hpp(109): note: see declaration of 'websocketpp::transport::asio::socket::socket_category::name' 1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name' 1>C:\websocketpp\websocketpp/processors/base.hpp(165): error C2694: 'const char *websocketpp::processor::error::processor_category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const' 1> C:\websocketpp\websocketpp/processors/base.hpp(165): note: see declaration of 'websocketpp::processor::error::processor_category::name' 1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name' 1>C:\websocketpp\websocketpp/common/md5.hpp(367): warning C4267: '+=': conversion from 'size_t' to 'websocketpp::md5::md5_word_t', possible loss of data 1>C:\websocketpp\websocketpp/sha1/sha1.hpp(176): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


回答1:


Defining _WEBSOCKETPP_NOEXCEPT_ and _WEBSOCKETPP_CPP11_CHRONO_ did the trick for me :) https://github.com/zaphoyd/websocketpp/issues/437



来源:https://stackoverflow.com/questions/32969289/error-in-websocketpp-library-and-boost-in-windows-visual-studio-2015

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!