First I'll give specific details about the problem I'm having, then I'll go into the interesting results I'm getting from nm when I try to debug the issue. Hopefully an nm guru will be able to interpret those results.
I've statically compiled the Casablanca C++ REST SDK to the library libcpprest.a. That works fine, but when I link against my code using the command:
/usr/bin/c++ CMakeFiles/dcodr_service.dir/dcodr_service.cc.o
CMakeFiles/dcodr_service.dir/viterbi.cc.o CMakeFiles/dcodr_service.dir/utils.cc.o
CMakeFiles/dcodr_service.dir/hmm.cc.o CMakeFiles/dcodr_service.dir/grammar.cc.o
-o dcodr_service -L/home/user/casablanca/Release/Binaries -rdynamic -lfftw3f
-lcpprest -lcommon_utilities -lboost_program_options -lboost_regex -lboost_system
-lboost_filesystem -lboost_iostreams /opt/OpenBLAS/lib/libopenblas.a -Wl,
-rpath,/home/user/casablanca/Release/Binaries
I get the error:
CMakeFiles/dcodr_service.dir/dcodr_service.cc.o: In function
`web::http::http_request::extract_json(bool)
const::{lambda(unsigned long)#1}::operator()(unsigned long) const':
/home/user/casablanca/Release/include/cpprest/http_msg.h:829:
undefined reference to `web::http::details::http_msg_base::_extract_json(bool)'
It appears that _extract_json(bool) is defined in http_msg.cpp, which also appears to be compiled when I look at the verbose output of making libcpprest.a. Now, running nm -e --demangle libcpprest.a I get the following two lines (separated by thousands of others):
00000000000015ee T web::http::details::http_msg_base::_extract_json(bool)
U web::http::details::http_msg_base::_extract_json(bool)
I'm new to using nm, but it appears to me that _extract_json(bool) is both in the code section and in the list of undefined symbols. Is there a better way of interpreting the nm results?
As an aside, when I compile cpprest as a dynamic library and link against it everything works fine, but for various reasons I have to create a static binary of dcodr_service.
EDIT: Following up on a comment from πάντα ῥεῖ, _extract_json(bool) is used in the following context:
return pplx::create_task(_m_impl->_get_data_available())
.then([impl, force](utility::size64_t) { return impl->_extract_json(force); });
That is, it is used inside a lambda function. Could that cause a linker error?