title: Undefined reference to boost asio
body: <p>I am having issues building with <code>opt</code> mode with <code>Bazel</code> and <code>boost</code>. Here is my error.</p>
  <pre><code>bazel-out/k8-opt/bin/src/_objs/wallet/message_store.o:message_store.cpp:function _GLOBAL__sub_I__ZN3mms13message_storeC2ESt10unique_ptrIN4epee9net_utils4http20abstract_http_clientESt14default_deleteIS5_EE: error: undefined reference to 'boost::asio::ssl::error::get_stream_category()'
  bazel-out/k8-opt/bin/src/_objs/wallet/wallet_rpc_payments.o:wallet_rpc_payments.cpp:function _GLOBAL__sub_I__ZNK5tools7wallet220get_client_signatureB5cxx11Ev: error: undefined reference to 'boost::asio::ssl::error::get_stream_category()'
  bazel-out/k8-opt/bin/src/_objs/wallet/wallet2.o:wallet2.cpp:function _GLOBAL__sub_I__ZN5tools7wallet227default_daemon_address_lockE: error: undefined reference to 'boost::asio::ssl::error::get_stream_category()'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function epee::net_utils::http::http_simple_client_template&lt;epee::net_utils::blocked_mode_client&gt;::set_server(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::optional&lt;epee::net_utils::http::login&gt;, epee::net_utils::ssl_options_t): error: undefined reference to 'boost::asio::ssl::context::operator=(boost::asio::ssl::context&amp;&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function epee::net_utils::http::http_simple_client_template&lt;epee::net_utils::blocked_mode_client&gt;::set_server(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::optional&lt;epee::net_utils::http::login&gt;, epee::net_utils::ssl_options_t): error: undefined reference to 'boost::asio::ssl::context::context(boost::asio::ssl::context_base::method)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function epee::net_utils::http::http_simple_client_template&lt;epee::net_utils::blocked_mode_client&gt;::set_server(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::optional&lt;epee::net_utils::http::login&gt;, epee::net_utils::ssl_options_t): error: undefined reference to 'boost::asio::ssl::context::operator=(boost::asio::ssl::context&amp;&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function std::_Sp_counted_ptr&lt;boost::asio::ssl::stream&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt; &gt;*, (__gnu_cxx::_Lock_policy)2&gt;::_M_dispose(): error: undefined reference to 'boost::asio::ssl::detail::engine::~engine()'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::stream_core::~stream_core(): error: undefined reference to 'boost::asio::ssl::detail::engine::~engine()'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::stream&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt; &gt;::stream&lt;boost::asio::io_context&amp;&gt;(boost::asio::io_context&amp;, boost::asio::ssl::context&amp;): error: undefined reference to 'boost::asio::ssl::context::native_handle()'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::stream&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt; &gt;::stream&lt;boost::asio::io_context&amp;&gt;(boost::asio::io_context&amp;, boost::asio::ssl::context&amp;): error: undefined reference to 'boost::asio::ssl::detail::engine::engine(ssl_ctx_st*)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::stream&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt; &gt;::stream&lt;boost::asio::io_context&amp;&gt;(boost::asio::io_context&amp;, boost::asio::ssl::context&amp;): error: undefined reference to 'boost::asio::ssl::detail::engine::~engine()'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::shutdown_op, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;boost::system::error_code&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::shutdown(boost::system::error_code&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::shutdown_op, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;boost::system::error_code&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::put_input(boost::asio::const_buffer const&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::shutdown_op, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;boost::system::error_code&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::shutdown(boost::system::error_code&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::shutdown_op, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;boost::system::error_code&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::get_output(boost::asio::mutable_buffer const&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::shutdown_op, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;boost::system::error_code&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::put_input(boost::asio::const_buffer const&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function net::http::client_factory::create(): error: undefined reference to 'boost::asio::ssl::context::context(boost::asio::ssl::context_base::method)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::write_op&lt;boost::asio::const_buffers_1&gt;, boost::asio::detail::write_op&lt;boost::asio::ssl::stream&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt; &gt;, boost::asio::const_buffers_1, boost::asio::const_buffer const*, boost::asio::detail::transfer_all_t, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;boost::system::error_code&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt; &gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::write(boost::asio::const_buffer const&amp;, boost::system::error_code&amp;, unsigned long&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::write_op&lt;boost::asio::const_buffers_1&gt;, boost::asio::detail::write_op&lt;boost::asio::ssl::stream&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt; &gt;, boost::asio::const_buffers_1, boost::asio::const_buffer const*, boost::asio::detail::transfer_all_t, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;boost::system::error_code&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt; &gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::put_input(boost::asio::const_buffer const&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::write_op&lt;boost::asio::const_buffers_1&gt;, boost::asio::detail::write_op&lt;boost::asio::ssl::stream&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt; &gt;, boost::asio::const_buffers_1, boost::asio::const_buffer const*, boost::asio::detail::transfer_all_t, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;boost::system::error_code&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt; &gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::write(boost::asio::const_buffer const&amp;, boost::system::error_code&amp;, unsigned long&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::write_op&lt;boost::asio::const_buffers_1&gt;, boost::asio::detail::write_op&lt;boost::asio::ssl::stream&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt; &gt;, boost::asio::const_buffers_1, boost::asio::const_buffer const*, boost::asio::detail::transfer_all_t, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;boost::system::error_code&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt; &gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::get_output(boost::asio::mutable_buffer const&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::write_op&lt;boost::asio::const_buffers_1&gt;, boost::asio::detail::write_op&lt;boost::asio::ssl::stream&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt; &gt;, boost::asio::const_buffers_1, boost::asio::const_buffer const*, boost::asio::detail::transfer_all_t, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;boost::system::error_code&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt; &gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::put_input(boost::asio::const_buffer const&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::read_op&lt;boost::asio::mutable_buffers_1&gt;, boost::asio::detail::read_op&lt;boost::asio::ssl::stream&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt; &gt;, boost::asio::mutable_buffers_1, boost::asio::mutable_buffer const*, boost::asio::detail::transfer_at_least_t, epee::net_utils::blocked_mode_client::handler_obj&gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::read(boost::asio::mutable_buffer const&amp;, boost::system::error_code&amp;, unsigned long&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::read_op&lt;boost::asio::mutable_buffers_1&gt;, boost::asio::detail::read_op&lt;boost::asio::ssl::stream&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt; &gt;, boost::asio::mutable_buffers_1, boost::asio::mutable_buffer const*, boost::asio::detail::transfer_at_least_t, epee::net_utils::blocked_mode_client::handler_obj&gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::read(boost::asio::mutable_buffer const&amp;, boost::system::error_code&amp;, unsigned long&amp;)'
  bazel-out/k8-opt/bin/src/_objs/net/http.o:http.cpp:function boost::asio::ssl::detail::io_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt;, boost::asio::ssl::detail::read_op&lt;boost::asio::mutable_buffers_1&gt;, boost::asio::detail::read_op&lt;boost::asio::ssl::stream&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::executor&gt; &gt;, boost::asio::mutable_buffers_1, boost::asio::mutable_buffer const*, boost::asio::detail::transfer_at_least_t, epee::net_utils::blocked_mode_client::handler_obj&gt; &gt;::operator()(boost::system::error_code, unsigned long, int): error: undefined reference to 'boost::asio::ssl::detail::engine::get_output(boost::asio::mutable_buffer const&amp;)'
  </code></pre>
  <p>My build file looks like the following.</p>
  <pre><code>cc_binary(
      name = &quot;denarii_wallet_cli&quot;,
      srcs = [
          &quot;simplewallet.cpp&quot;,
          &quot;simplewallet.h&quot;,
      ],
      linkopts = [
          &quot;-lssl&quot;,
          &quot;-lcrypto&quot;,
          &quot;-ldl&quot;,
          &quot;-lpthread&quot;,
          &quot;-lboost_system&quot;,
          &quot;-lboost_thread&quot;,
      ],
      deps = [
          &quot;//contrib/epee&quot;,
          &quot;//src:cncrypto&quot;,
          &quot;//src:common&quot;,
          &quot;//src:cryptonote_core&quot;,
          &quot;//src:cryptonote_protocol&quot;,
          &quot;//src:rpc_base&quot;,
          &quot;//src:version&quot;,
          &quot;//src:wallet&quot;,
          &quot;//src/mnemonics&quot;,
          &quot;@boost//:asio&quot;,
          &quot;@boost//:chrono&quot;,
          &quot;@boost//:filesystem&quot;,
          &quot;@boost//:locale&quot;,
          &quot;@boost//:program_options&quot;,
          &quot;@boost//:system&quot;,
          &quot;@boost//:thread&quot;,
          &quot;@liblzma&quot;,
          &quot;@libreadline&quot;,
          &quot;@openssl//:libcrypto&quot;,
          &quot;@openssl//:libssl&quot;,
          &quot;@qrcodegen&quot;,
      ],
  )
  
  </code></pre>
  <p>It builds fine in <code>dbg</code> and <code>fastbuild</code> modes. So I have no clue why this isn't working. I can provide more info if people have other questions I just don't know what to provide :)</p>
  <p>I have also seen other similar issues like: <a href="https://stackoverflow.com/questions/35154639/undefined-reference-to-boostsystemgeneric-category-when-adding-boost-asi">undefined reference to `boost::system::generic_category()&#39; when adding boost/asio</a></p>