My code used to copmile well previously, until boost library got updated with changes in asio
.
In my code, I define a variable: boost::shared_ptr<Face> face(boost::make_shared<ThreadsafeFace>(io_service));
which, as can be seen, takes io_service
for the constructor. Face
and ThreadsafeFace
are a library classes, my app links to.
The problem occurs at linking stage of my binary, where I get undefined symbols
error:
Undefined symbols for architecture x86_64:
"ndn::ThreadsafeFace::ThreadsafeFace(boost::asio::io_context&)", referenced from:
boost::detail::sp_if_not_array<ndn::ThreadsafeFace>::type boost::make_shared<ndn::ThreadsafeFace, boost::asio::io_context&>(boost::asio::io_context&&&) in ndnrtc_client-main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
As can be seen, linker can't find a constructor for ThreadsafeFace
that takes boost::asio::io_context&
argument. And it won't -- because library does not provide one. The only one library does provide -- is with io_service
argument.
Now, I don't quite understand, where does this constructor definition come from, as neither my code, nor library's code have this definition.
This makes me think that with new boost (I'm linking against 1.67 using homebrew, macOS), io_service
gets replaced by io_context
automatically (during preprocessing?), thus leading to the problem.
I tried providing -DBOOST_ASIO_ENABLE_OLD_SERVICES
when compiling my code, but it didn't help either.
Shall I downgrade boost version until library gets updated?
UPDATE
I've ran clang
for preprocessing (clang++ -E ...
) and found this in the output:
# 21 "/usr/local/include/boost/asio/io_service.hpp" 2 3
namespace boost {
namespace asio {
typedef io_context io_service;
}
}
Which confirms that all io_service
variables will in fact be io_context
and guarantee headaches.