sony / nmos-cpp

An NMOS (Networked Media Open Specifications) Registry and Node in C++ (IS-04, IS-05)
Apache License 2.0
136 stars 80 forks source link

build fails with compilation error: error: ‘class web::websockets::client::websocket_client_config’ has no member named ‘set_ssl_context_callback’ #392

Closed gururajsb13 closed 4 weeks ago

gururajsb13 commented 1 month ago

Hi,

We are using the Conan package manager to manage dependencies instead of installing them separately. We cloned the master branch with last commit:7949ab559f30b392f2282ceee16ddeee2aebdec6.

Below is the output of the Conan profile: _makefile Copy code [settings] arch=armv7 buildtype=Release compiler=gcc compiler.cppstd=gnu14 compiler.libcxx=libstdc++11 compiler.version=8 os=Linux

We have been successfully building nmos-cpp on this system until now. However, with the latest code from the master branch, we started encountering the following compilation errors:

_[ 74%] Building CXX object CMakeFiles/nmos-cpp.dir/nmos/channelmapping_resources.cpp.o [ 74%] Building CXX object CMakeFiles/nmos-cpp.dir/nmos/channels.cpp.o [ 74%] Building CXX object CMakeFiles/nmos-cpp.dir/nmos/client_utils.cpp.o /home/debian/nmos_latest/nmos-cpp/Development/nmos/client_utils.cpp: In function ‘web::websockets::client::websocket_client_config nmos::make_websocket_client_config(bool, const settings&, nmos::load_ca_certificates_handler, slog::base_gate&)’: /home/debian/nmos_latest/nmos-cpp/Development/nmos/client_utils.cpp:228:28: error: ‘class web::websockets::client::websocket_client_config’ has no member named ‘set_ssl_context_callback’ if (secure) config.set_ssl_context_callback(details::make_client_ssl_context_callback(settings, load_ca_certificates, gate)); ^~~~~~~~ In file included from /home/debian/nmos_latest/nmos-cpp/Development/nmos/client_utils.cpp:12: /home/debian/nmos_latest/nmos-cpp/Development/cpprest/details/system_error.h: In instantiation of ‘ExceptionType web::details::from_boost_system_system_error(const boost::system::system_error&) [with ExceptionType = web::http::http_exception]’: /home/debian/nmos_latest/nmos-cpp/Development/nmos/client_utils.cpp:60:86: required from ‘std::function<void(boost::asio::ssl::context&)> nmos::details::make_client_ssl_context_callback(const settings&, nmos::load_ca_certificates_handler, slog::base_gate&) [with ExceptionType = web::http::http_exception; nmos::settings = web::json::value; nmos::load_ca_certificates_handler = std::function<std::__cxx11::basic_string()>]’ /home/debian/nmos_latest/nmos-cpp/Development/nmos/client_utils.cpp:168:158: required from here /home/debian/nmos_latest/nmos-cpp/Development/cpprest/details/system_error.h:71:20: error: no matching function for call to ‘web::http::http_exception::http_exception(std::error_code, const char*)’ return ExceptionType(to_std_errorcode(e.code()), e.what()); ^~~~~~~~~~~~

I then updated my Conan package manager to version 2.0.17 and CMake to create the build files. However, the compilation (make) still fails with the same error.

Could you please advise on how to resolve this issue?

Thanks in advance, -Guru

garethsb commented 1 month ago

@gururajsb13, judging from these error messages somehow you have a very old version of cpprestsdk, v2.10.10 or earlier.

/home/debian/nmos_latest/nmos-cpp/Development/nmos/client_utils.cpp:228:28: error: ‘class web::websockets::client::websocket_client_config’ has no member named ‘set_ssl_context_callback’

In recent versions the preprocessor condition is the same for the declaration in cpprestsdk and the usage in nmos-cpp...

https://github.com/microsoft/cpprestsdk/blob/411a109150b270f23c8c97fa4ec9a0a4a98cdecf/Release/include/cpprest/ws_client.h#L182

https://github.com/sony/nmos-cpp/blob/0a29731aab4bcd5b6b0a1023c74ea0114312fcdd/Development/nmos/client_utils.cpp#L227

(After 5 years I can't remember a good reason why it's that condition, but it's the same in both code bases, and on Linux neither _WIN32 nor __cplusplus_winrt should be defined. ARM vs x86 shouldn't make any difference either.)

You'd have to go back to cpprestsdk v2.10.10 for that member function not to exist: https://github.com/microsoft/cpprestsdk/blob/v2.10.10/Release/include/cpprest/ws_client.h

That would also explain the second error:

no matching function for call to ‘web::http::http_exception::http_exception(std::error_code, const char*)’

That overload also arrived between cpprestsdk v2.10.10 and v2.10.11, see https://github.com/microsoft/cpprestsdk/commit/43773b9858f0672a4d5856a48f79d97193b295d9.

Please check your full build logs to see how it could be picking up an old cpprestsdk on your system.

gururajsb13 commented 4 weeks ago

@garethsb after installing cpprestsdk version 2.10.14, I have successfully resolved the compilation error previously encountered. I can now build and generate the NMOS binary without any issues.

Thank you for your assistance to resolve this issue. I'll be Closing this ticket.