Building libtorrent fails with compilation erros when building boost library

145 views Asked by At

I am trying to build libtorrent on RHEL 9 which supports Python 3.9. I am using the following libraries for to make libtorrent.

boost-pic-1.65.1.tgz
libtorrent-rasterbar-1.1.5.tar.gz

During make process, it fails with compilation errors when trying to make boost library.

make[3]: Entering directory '/grid/0/jenkins/cmf/build/redhat9/libtorrent/build/src'
  CXX      session_impl.lo
In file included from /grid/0/jenkins/cmf/build/redhat9/boost//include/boost/bind.hpp:22,
                 from session_impl.cpp:51:
/grid/0/jenkins/cmf/build/redhat9/boost//include/boost/bind/bind.hpp: In instantiation of 'struct boost::_bi::add_cref<bool (boost::shared_ptr<libtorrent::peer_connection>::*)() const noexcept, 1>':
/grid/0/jenkins/cmf/build/redhat9/boost//include/boost/bind/bind.hpp:2286:46:   required from 'struct boost::_bi::dm_result<bool (boost::shared_ptr<libtorrent::peer_connection>::*)() const noexcept, boost::arg<1> >'
/grid/0/jenkins/cmf/build/redhat9/boost//include/boost/bind/bind.hpp:2305:1:   required by substitution of 'template<class A1, class M, class T> boost::_bi::bind_t<typename boost::_bi::dm_result<M T::*, A1>::type, boost::_mfi::dm<M, T>, typename boost::_bi::list_av_1<A1>::type> boost::bind(M T::*, A1) [with A1 = boost::arg<1>; M = bool() const noexcept; T = boost::shared_ptr<libtorrent::peer_connection>]'
session_impl.cpp:3036:18:   required from here
/grid/0/jenkins/cmf/build/redhat9/boost//include/boost/bind/bind.hpp:2249:23: error: forming reference to qualified function type 'bool() const noexcept'
 2249 |     typedef M const & type;
      |                       ^~~~
In file included from /grid/0/jenkins/cmf/build/redhat9/boost//include/boost/bind.hpp:22,
                 from session_impl.cpp:51:
/grid/0/jenkins/cmf/build/redhat9/boost//include/boost/bind/bind.hpp: In instantiation of 'struct boost::_bi::result_traits<boost::_bi::unspecified, bool (boost::shared_ptr<libtorrent::peer_connection>::*)() const noexcept>':
/grid/0/jenkins/cmf/build/redhat9/boost//include/boost/bind/bind.hpp:1284:48:   required from 'class boost::_bi::bind_t<boost::_bi::unspecified, bool (boost::shared_ptr<libtorrent::peer_connection>::*)() const noexcept, boost::_bi::list1<boost::arg<1> > >'
session_impl.cpp:3036:18:   required from here
/grid/0/jenkins/cmf/build/redhat9/boost//include/boost/bind/bind.hpp:75:37: error: 'bool (boost::shared_ptr<libtorrent::peer_connection>::*)() const noexcept' is not a class, struct, or union type
   75 |     typedef typename F::result_type type;
      |                                     ^~~~
In file included from /usr/include/c++/11/bits/stl_algobase.h:71,
                 from /usr/include/c++/11/algorithm:61,
                 from session_impl.cpp:38:

Please suggests

  1. why the error is happening? I am not completely sure what the error suggests exactly. I have not worked with cpp extensively.
  2. What solutions can I try to overcome this?

Any pointers would be appreciated. I am newbie to libtorrent and cpp stuff. Thanks.

1

There are 1 answers

8
sehe On

I was able to build libtorrent on CentOS just now from a fresh install with

yum install -y git gcc-c++ make cmake boost boost-devel
git clone --recurse-submodules https://github.com/arvidn/libtorrent.git
cd libtorrent/
cmake -B build 

enter image description here

Now building using

make -C build -j

ran into a compiler error:

enter image description here

The key is:

/libtorrent/src/socket_type.cpp:107:17: note:   passing ‘const libtorrent::aux::idx_visitor*’ as ‘this’ argument discards qualifiers

I patched that to be more const-correct:

diff --git a/src/socket_type.cpp b/src/socket_type.cpp
index a1361dcfb..bf8f3f67c 100644
--- a/src/socket_type.cpp
+++ b/src/socket_type.cpp
@@ -99,18 +99,18 @@ namespace aux {
 #endif
 
        struct idx_visitor {
-               socket_type_t operator()(tcp::socket const&) { return socket_type_t::tcp; }
-               socket_type_t operator()(socks5_stream const&) { return socket_type_t::socks5; }
-               socket_type_t operator()(http_stream const&) { return socket_type_t::http; }
-               socket_type_t operator()(utp_stream const&) { return socket_type_t::utp; }
+               socket_type_t operator()(tcp::socket const&) const { return socket_type_t::tcp; }
+               socket_type_t operator()(socks5_stream const&) const { return socket_type_t::socks5; }
+               socket_type_t operator()(http_stream const&) const { return socket_type_t::http; }
+               socket_type_t operator()(utp_stream const&) const { return socket_type_t::utp; }
 #if TORRENT_USE_I2P
-               socket_type_t operator()(i2p_stream const&) { return socket_type_t::i2p; }
+               socket_type_t operator()(i2p_stream const&) const { return socket_type_t::i2p; }
 #endif
 #if TORRENT_USE_SSL
-               socket_type_t operator()(ssl_stream<tcp::socket> const&) { return socket_type_t::tcp_ssl; }
-               socket_type_t operator()(ssl_stream<socks5_stream> const&) { return socket_type_t::socks5_ssl; }
-               socket_type_t operator()(ssl_stream<http_stream> const&) { return socket_type_t::http_ssl; }
-               socket_type_t operator()(ssl_stream<utp_stream> const&) { return socket_type_t::utp_ssl; }
+               socket_type_t operator()(ssl_stream<tcp::socket> const&) const { return socket_type_t::tcp_ssl; }
+               socket_type_t operator()(ssl_stream<socks5_stream> const&) const { return socket_type_t::socks5_ssl; }
+               socket_type_t operator()(ssl_stream<http_stream> const&) const { return socket_type_t::http_ssl; }
+               socket_type_t operator()(ssl_stream<utp_stream> const&) const { return socket_type_t::utp_ssl; }
 #endif
        };

And now it builds completely:

enter image description here