I am trying out boost::fiber library, but I couldn't manage to compile code with boost fiber. Therefore I turned into compiling and running boost official examples. I installed latest version of boost library 1.65.1, and installation seems to be fine. I executed following command to compile simple.cpp
g++ -I /usr/local/include/boost/ -L /usr/local/lib/ -lboost_fiber -std=c++11 libs/fiber/examples/simple.cpp
But I get the following complains:
/tmp/ccWQ5ZMf.o: In function `main':
simple.cpp:(.text+0x7b): undefined reference to `boost::fibers::fiber::join()'
/tmp/ccWQ5ZMf.o: In function `boost::context::continuation::~continuation()':
simple.cpp:(.text._ZN5boost7context12continuationD2Ev[_ZN5boost7context12continuationD5Ev]+0x59): undefined reference to `ontop_fcontext'
/tmp/ccWQ5ZMf.o: In function `boost::context::continuation::resume()':
simple.cpp:(.text._ZN5boost7context12continuation6resumeEv[_ZN5boost7context12continuation6resumeEv]+0x68): undefined reference to `jump_fcontext'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::context::context(unsigned long, boost::fibers::type, boost::fibers::launch)':
simple.cpp:(.text._ZN5boost6fibers7contextC2EmNS0_4typeENS0_6launchE[_ZN5boost6fibers7contextC5EmNS0_4typeENS0_6launchE]+0x18): undefined reference to `vtable for boost::fibers::context'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::fiber::get_id() const':
simple.cpp:(.text._ZNK5boost6fibers5fiber6get_idEv[_ZNK5boost6fibers5fiber6get_idEv]+0x3b): undefined reference to `boost::fibers::context::get_id() const'
/tmp/ccWQ5ZMf.o: In function `boost::this_fiber::yield()':
simple.cpp:(.text._ZN5boost10this_fiber5yieldEv[_ZN5boost10this_fiber5yieldEv]+0x5): undefined reference to `boost::fibers::context::active()'
simple.cpp:(.text._ZN5boost10this_fiber5yieldEv[_ZN5boost10this_fiber5yieldEv]+0xd): undefined reference to `boost::fibers::context::yield()'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::fiber::fiber<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int, void, void, void>(void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int)':
simple.cpp:(.text._ZN5boost6fibers5fiberC2IRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEvvvEEOT_DpT0_[_ZN5boost6fibers5fiberC5IRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEvvvEEOT_DpT0_]+0x2c): undefined reference to `boost::context::stack_traits::default_size()'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::fiber::fiber<boost::context::basic_fixedsize_stack<boost::context::stack_traits>, void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>(boost::fibers::launch, std::allocator_arg_t, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int)':
simple.cpp:(.text._ZN5boost6fibers5fiberC2INS_7context21basic_fixedsize_stackINS3_12stack_traitsEEERFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEENS0_6launchESt15allocator_arg_tT_OT0_DpT1_[_ZN5boost6fibers5fiberC5INS_7context21basic_fixedsize_stackINS3_12stack_traitsEEERFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEENS0_6launchESt15allocator_arg_tT_OT0_DpT1_]+0x7f): undefined reference to `boost::fibers::fiber::start_()'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::worker_context<boost::context::basic_fixedsize_stack<boost::context::stack_traits> >(boost::fibers::launch, boost::context::preallocated const&, boost::context::basic_fixedsize_stack<boost::context::stack_traits> const&, void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int)':
simple.cpp:(.text._ZN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEC2INS_7context21basic_fixedsize_stackINSG_12stack_traitsEEEEENS0_6launchERKNSG_12preallocatedERKT_SB_SD_i[_ZN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEC5INS_7context21basic_fixedsize_stackINSG_12stack_traitsEEEEENS0_6launchERKNSG_12preallocatedERKT_SB_SD_i]+0x15d): undefined reference to `boost::fibers::context::~context()'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::run_(boost::context::continuation&&)':
simple.cpp:(.text._ZN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEE4run_EONS_7context12continuationE[_ZN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEE4run_EONS_7context12continuationE]+0xb5): undefined reference to `boost::fibers::context::terminate()'
/tmp/ccWQ5ZMf.o: In function `void* boost::context::detail::create_context2<boost::context::detail::record<boost::context::continuation, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<std::_Mem_fn<boost::context::continuation (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::*)(boost::context::continuation&&)> (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>*, std::_Placeholder<1>)> >, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<std::_Mem_fn<boost::context::continuation (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::*)(boost::context::continuation&&)> (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>*, std::_Placeholder<1>)> >(boost::context::preallocated, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<std::_Mem_fn<boost::context::continuation (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::*)(boost::context::continuation&&)> (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>*, std::_Placeholder<1>)>&&)':
simple.cpp:(.text._ZN5boost7context6detail15create_context2INS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEES7_SX_EEPvNS0_12preallocatedET0_OT1_[_ZN5boost7context6detail15create_context2INS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEES7_SX_EEPvNS0_12preallocatedET0_OT1_]+0xd8): undefined reference to `make_fcontext'
simple.cpp:(.text._ZN5boost7context6detail15create_context2INS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEES7_SX_EEPvNS0_12preallocatedET0_OT1_[_ZN5boost7context6detail15create_context2INS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEES7_SX_EEPvNS0_12preallocatedET0_OT1_]+0x10f): undefined reference to `jump_fcontext'
/tmp/ccWQ5ZMf.o: In function `void boost::context::detail::context_entry<boost::context::detail::record<boost::context::continuation, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<std::_Mem_fn<boost::context::continuation (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::*)(boost::context::continuation&&)> (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>*, std::_Placeholder<1>)> > >(boost::context::detail::transfer_t)':
simple.cpp:(.text._ZN5boost7context6detail13context_entryINS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEEEEvNS1_10transfer_tE[_ZN5boost7context6detail13context_entryINS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEEEEvNS1_10transfer_tE]+0x70): undefined reference to `jump_fcontext'
simple.cpp:(.text._ZN5boost7context6detail13context_entryINS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEEEEvNS1_10transfer_tE[_ZN5boost7context6detail13context_entryINS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEEEEvNS1_10transfer_tE]+0xc9): undefined reference to `ontop_fcontext'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::~worker_context()':
simple.cpp:(.text._ZN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEED2Ev[_ZN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEED5Ev]+0x20): undefined reference to `boost::fibers::context::~context()'
/tmp/ccWQ5ZMf.o:(.rodata._ZTIN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEE[_ZTIN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEE]+0x10): undefined reference to `typeinfo for boost::fibers::context'
collect2: error: ld returned 1 exit status
Libraries (-l) should be specified after source/object files. The best place to specify -l is at the end of the command.
And boost_fiber depends upon boost_context.
So you'll need -lboost_fiber -lboost_context at the end of the command line.
Related
I'm trying to link protobuf but I'm getting an undefined reference:
this is my CMAKE file:
I also see in the error code it has a problem with the std::string of the ABI of CPP11 but I don't know if this is the main problem or not because I'm building from a source using GCC 7.3.1
cmake_minimum_required(VERSION 3.17)
project(cpp_server_side_objects)
set(CMAKE_CXX_STANDARD 17)
SET(BOOST_LIB boost_system boost_thread)
INCLUDE(FindProtobuf)
FIND_PACKAGE(Protobuf REQUIRED)
if(Protobuf_VERBOSE)
message(STATUS "Using Protocol Buffers ${Protobuf_VERSION}")
else()
message(STATUS "cant find protobuf ${Protobuf_VERSION}")
endif()
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HEADER SREXOrderRequest.proto)
ADD_LIBRARY(proto ${PROTO_HEADER} ${PROTO_SRC})
add_executable(cpp_server_side_objects main.cpp request.cpp request.h)
target_link_libraries(cpp_server_side_objects proto ${PROTOBUF_LIBRARY} ${BOOST_LIB} )
but I'm getting this error messages:
====================[ Build | cpp_server_side_objects | Debug ]=================
/home/yaodav/clion-2019.1.4/bin/cmake/linux/bin/cmake --build /home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug --target cpp_server_side_objects -- -j 4
[ 25%] Linking CXX executable cpp_server_side_objects
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__symbol(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:618: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__myid(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:691: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__exdest(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:764: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__userinfo(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:837: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__dest(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:910: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::SREXOrderRequest(server_side_order::SREXOrderRequest const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:155: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:160: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:165: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:170: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:175: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_InternalParse(char const*, google::protobuf::internal::ParseContext*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:325: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:336: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:347: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:358: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:369: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `google::protobuf::internal::ArenaStringPtr::Swap(google::protobuf::internal::ArenaStringPtr*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, google::protobuf::Arena*)':
/usr/local/include/google/protobuf/arenastring.h:326: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
/usr/local/include/google/protobuf/arenastring.h:327: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
/usr/local/include/google/protobuf/arenastring.h:326: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
/usr/local/include/google/protobuf/arenastring.h:327: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
/usr/local/include/google/protobuf/arenastring.h:326: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o:/usr/local/include/google/protobuf/arenastring.h:327: more undefined references to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)' follow
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliased(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)':
/usr/local/include/google/protobuf/io/coded_stream.h:719: undefined reference to `google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliasedOutline(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__symbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:607: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__symbol[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:630: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__myid(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:680: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__myid[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:703: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__exdest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:753: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__exdest[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:776: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__userinfo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:826: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__userinfo[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:849: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__dest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:899: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__dest[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:922: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o:(.rodata._ZTVN17server_side_order16SREXOrderRequestE[_ZTVN17server_side_order16SREXOrderRequestE]+0x20): undefined reference to `google::protobuf::Message::GetTypeName[abi:cxx11]() const'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o:(.rodata._ZTVN17server_side_order16SREXOrderRequestE[_ZTVN17server_side_order16SREXOrderRequestE]+0x48): undefined reference to `google::protobuf::Message::InitializationErrorString[abi:cxx11]() const'
collect2: error: ld returned 1 exit status
gmake[3]: *** [cpp_server_side_objects] Error 1
gmake[2]: *** [CMakeFiles/cpp_server_side_objects.dir/all] Error 2
gmake[1]: *** [CMakeFiles/cpp_server_side_objects.dir/rule] Error 2
gmake: *** [cpp_server_side_objects] Error 2
how to fix it?
tried using this and this and this and with this also with no luck.
I had a similar problem. The protobuf_generate_cpp command in CMake seems to cause a problem in linking the source and header files created from the *.proto file with the necessary libraries.
My workaround was as follows. After obtaining the files created from the proto file, it was to close it so that it would not be created again.
# ---------------------------------------------------------------
## Protocol Buffers
set(CMAKE_PREFIX_PATH "C:\\DevTools\\vcpkg\\packages\\protobuf_x64-windows" "${CMAKE_PREFIX_PATH}")
set(PROTOBUF_INCLUDE_DIR "C:\\DevTools\\vcpkg\\packages\\protobuf_x64-windows\\include")
include(FindProtobuf)
find_package(Protobuf CONFIG REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
#protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS src/protocolbuffers/person.proto) # this line
# copy the generated files to the build directory
file(COPY ${PROTO_HDRS} DESTINATION src/protocolbuffers)
file(COPY ${PROTO_SRCS} DESTINATION src/protocolbuffers)
message(STATUS "debug protobuf lib location:${PROTOBUF_LIBRARY}")
message(STATUS "debug protobuf include location:${PROTOBUF_INCLUDE_DIR}")
message(STATUS "proto source files:${PROTO_SRCS}")
message(STATUS "proto header files:${PROTO_HDRS}")
# ---------------------------------------------------------------
...
add_executable(${PROJECT_NAME}
${SOURCE_FILES}
${HEADER_FILES}
${PROTO_SRCS} ${PROTO_HDRS}
)
...
target_link_libraries(${PROJECT_NAME} PRIVATE
...
${Protobuf_LIBRARIES}
protobuf::libprotobuf
)
Context
I have pulled code from the concord repo at https://github.com/vmware/concord. I managed to build the docker images fine.
In the documentation at https://concord.readthedocs.io/en/latest/deployment/deployment.html#confguration-file-generator they mention a configuration file generator that is used to generate configuration files which is required to run a concord node using docker run (the command to run the concord node is defined at https://concord.readthedocs.io/en/latest/deployment/deployment.html#concord-nodes). This configuration file generator is a .cpp called conc_genconfig.cpp (available at https://github.com/vmware/concord/blob/master/tools/conc_genconfig.cpp) and requires a .yml as an input. This uses library files from log4cplus and boost. I installed these by looking at the Dockerfile under the builder folder (available at https://github.com/vmware/concord/blob/master/docker/dockerfiles/builder/Dockerfile)
Problem
When I compile conc_genconfig.cpp using the following command:
g++ -Wall -g -std=c++11 -LLIBDIR -I /home/ubuntu/concord/src -I /home/ubuntu/concord-bft/threshsign/include/threshsign conc_genconfig.cpp
I get the following output/compilation errors:
In file included from conc_genconfig.cpp:23:0:
/home/ubuntu/concord/src/config/configuration_manager.hpp:1547:23: warning: inline variables are only available with -std=c++1z or -std=gnu++1z
kPositiveIntLimits({1, INT_MAX});
^
/home/ubuntu/concord/src/config/configuration_manager.hpp:1549:26: warning: inline variables are only available with -std=c++1z or -std=gnu++1z
kPositiveUInt16Limits({1, UINT16_MAX});
^
/home/ubuntu/concord/src/config/configuration_manager.hpp:1551:26: warning: inline variables are only available with -std=c++1z or -std=gnu++1z
kPositiveUInt64Limits({1, UINT64_MAX});
^
/home/ubuntu/concord/src/config/configuration_manager.hpp:1553:29: warning: inline variables are only available with -std=c++1z or -std=gnu++1z
kPositiveULongLongLimits({1, ULLONG_MAX});
^
/home/ubuntu/concord/src/config/configuration_manager.hpp:1554:77: warning: inline variables are only available with -std=c++1z or -std=gnu++1z
inline const std::pair<unsigned long long, unsigned long long> kUInt16Limits(
^
/home/ubuntu/concord/src/config/configuration_manager.hpp:1556:77: warning: inline variables are only available with -std=c++1z or -std=gnu++1z
inline const std::pair<unsigned long long, unsigned long long> kUInt32Limits(
^
/home/ubuntu/concord/src/config/configuration_manager.hpp:1558:77: warning: inline variables are only available with -std=c++1z or -std=gnu++1z
inline const std::pair<unsigned long long, unsigned long long> kUInt64Limits(
^
/home/ubuntu/concord/src/config/configuration_manager.hpp:1560:58: warning: inline variables are only available with -std=c++1z or -std=gnu++1z
inline const std::pair<long long, long long> kInt32Limits({INT32_MIN,
^
/home/ubuntu/concord/src/config/configuration_manager.hpp:1566:45: warning: inline variables are only available with -std=c++1z or -std=gnu++1z
kConcordBFTCommunicationBufferSizeLimits({512, UINT32_MAX});
^
/tmp/cc2pIDGw.o: In function `main':
/home/ubuntu/concord/tools/conc_genconfig.cpp:44: undefined reference to `log4cplus::initialize()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:45: undefined reference to `log4cplus::Logger::getDefaultHierarchy()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:45: undefined reference to `log4cplus::BasicConfigurator::BasicConfigurator(log4cplus::Hierarchy&, bool)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:46: undefined reference to `log4cplus::PropertyConfigurator::configure()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:48: undefined reference to `log4cplus::Logger::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:54: undefined reference to `boost::program_options::variables_map::variables_map()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:55: undefined reference to `boost::program_options::options_description::m_default_line_length'
/home/ubuntu/concord/tools/conc_genconfig.cpp:55: undefined reference to `boost::program_options::options_description::m_default_line_length'
/home/ubuntu/concord/tools/conc_genconfig.cpp:55: undefined reference to `boost::program_options::options_description::options_description(unsigned int, unsigned int)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:58: undefined reference to `boost::program_options::options_description::add_options()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:59: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:63: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:70: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:71: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:85: undefined reference to `boost::program_options::store(boost::program_options::basic_parsed_options<char> const&, boost::program_options::variables_map&, bool)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:92: undefined reference to `boost::program_options::operator<<(std::ostream&, boost::program_options::options_description const&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:95: undefined reference to `boost::program_options::notify(boost::program_options::variables_map&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:97: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:97: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:97: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:100: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:100: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:100: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:108: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:108: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:108: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:114: undefined reference to `concord::config::YAMLConfigurationInput::YAMLConfigurationInput(std::istream&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:116: undefined reference to `concord::config::YAMLConfigurationInput::parseInput()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:129: undefined reference to `concord::config::ConcordConfiguration::ConcordConfiguration()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:130: undefined reference to `concord::config::specifyConfiguration(concord::config::ConcordConfiguration&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:131: undefined reference to `concord::config::ConcordConfiguration::setConfigurationStateLabel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:134: undefined reference to `concord::config::loadClusterSizeParameters(concord::config::YAMLConfigurationInput&, concord::config::ConcordConfiguration&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:141: undefined reference to `concord::config::instantiateTemplatedConfiguration(concord::config::YAMLConfigurationInput&, concord::config::ConcordConfiguration&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:150: undefined reference to `concord::config::loadConfigurationInputParameters(concord::config::YAMLConfigurationInput&, concord::config::ConcordConfiguration&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:156: undefined reference to `concord::config::ConcordConfiguration::loadAllDefaults(bool, bool)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:158: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:158: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:158: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:164: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:164: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:164: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:167: undefined reference to `concord::config::generateConfigurationKeys(concord::config::ConcordConfiguration&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:168: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:168: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:168: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:177: undefined reference to `concord::config::ConcordConfiguration::generateAll(bool, bool)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:179: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:179: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:179: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:185: undefined reference to `concord::config::ConcordConfiguration::scopeIsInstantiated(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:186: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:186: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:186: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:192: undefined reference to `concord::config::ConcordConfiguration::validateAll(bool, bool)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:194: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:194: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:194: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:199: undefined reference to `concord::config::hasAllParametersRequiredAtConfigurationGeneration(concord::config::ConcordConfiguration&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:200: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:200: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:200: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:205: undefined reference to `concord::config::ConcordConfiguration::scopeSize(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:210: undefined reference to `concord::config::YAMLConfigurationOutput::YAMLConfigurationOutput(std::ostream&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:212: undefined reference to `concord::config::outputConcordNodeConfiguration(concord::config::ConcordConfiguration const&, concord::config::YAMLConfigurationOutput&, unsigned long)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:222: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:222: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:222: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:222: undefined reference to `concord::config::YAMLConfigurationOutput::~YAMLConfigurationOutput()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:231: undefined reference to `concord::config::outputPrincipalLocationsMappingJSON(concord::config::ConcordConfiguration&, std::ostream&)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:241: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:241: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:241: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:129: undefined reference to `concord::config::ConcordConfiguration::~ConcordConfiguration()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:114: undefined reference to `concord::config::YAMLConfigurationInput::~YAMLConfigurationInput()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:48: undefined reference to `log4cplus::Logger::~Logger()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:45: undefined reference to `log4cplus::BasicConfigurator::~BasicConfigurator()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:118: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:118: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:118: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:124: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:124: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:124: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:136: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:136: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:136: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:143: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:143: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:143: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:152: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:152: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:152: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:170: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:170: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:170: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:173: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:173: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:173: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:214: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:214: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:214: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:218: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:218: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:218: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:210: undefined reference to `concord::config::YAMLConfigurationOutput::~YAMLConfigurationOutput()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:233: undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
/home/ubuntu/concord/tools/conc_genconfig.cpp:233: undefined reference to `log4cplus::detail::get_macro_body_oss[abi:cxx11]()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:233: undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
/home/ubuntu/concord/tools/conc_genconfig.cpp:129: undefined reference to `concord::config::ConcordConfiguration::~ConcordConfiguration()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:114: undefined reference to `concord::config::YAMLConfigurationInput::~YAMLConfigurationInput()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:48: undefined reference to `log4cplus::Logger::~Logger()'
/home/ubuntu/concord/tools/conc_genconfig.cpp:45: undefined reference to `log4cplus::BasicConfigurator::~BasicConfigurator()'
/tmp/cc2pIDGw.o: In function `boost::program_options::value_semantic_codecvt_helper<char>::value_semantic_codecvt_helper()':
/usr/include/boost/program_options/value_semantic.hpp:91: undefined reference to `vtable for boost::program_options::value_semantic_codecvt_helper<char>'
/tmp/cc2pIDGw.o: In function `boost::program_options::value_semantic_codecvt_helper<char>::~value_semantic_codecvt_helper()':
/usr/include/boost/program_options/value_semantic.hpp:91: undefined reference to `vtable for boost::program_options::value_semantic_codecvt_helper<char>'
/tmp/cc2pIDGw.o: In function `boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, char const* const*)':
/usr/include/boost/program_options/detail/parsers.hpp:44: undefined reference to `boost::program_options::detail::cmdline::cmdline(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)'
/tmp/cc2pIDGw.o: In function `boost::program_options::basic_command_line_parser<char>::options(boost::program_options::options_description const&)':
/usr/include/boost/program_options/detail/parsers.hpp:52: undefined reference to `boost::program_options::detail::cmdline::set_options_description(boost::program_options::options_description const&)'
/tmp/cc2pIDGw.o: In function `boost::program_options::basic_command_line_parser<char>::run()':
/usr/include/boost/program_options/detail/parsers.hpp:108: undefined reference to `boost::program_options::detail::cmdline::get_canonical_option_prefix()'
/usr/include/boost/program_options/detail/parsers.hpp:109: undefined reference to `boost::program_options::detail::cmdline::run()'
/tmp/cc2pIDGw.o: In function `std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > boost::program_options::to_internal<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)':
/usr/include/boost/program_options/detail/convert.hpp:79: undefined reference to `boost::program_options::to_internal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/cc2pIDGw.o:(.data.rel.ro._ZTVN5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEE[_ZTVN5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEE]+0x38): undefined reference to `boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool) const'
/tmp/cc2pIDGw.o:(.data.rel.ro._ZTIN5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEE[_ZTIN5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEE]+0x18): undefined reference to `typeinfo for boost::program_options::value_semantic_codecvt_helper<char>'
/tmp/cc2pIDGw.o: In function `boost::program_options::variables_map::~variables_map()':
/usr/include/boost/program_options/variables_map.hpp:146: undefined reference to `vtable for boost::program_options::variables_map'
/tmp/cc2pIDGw.o: In function `boost::program_options::typed_value<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char>::name() const':
/usr/include/boost/program_options/detail/value_semantic.hpp:22: undefined reference to `boost::program_options::arg[abi:cxx11]'
/tmp/cc2pIDGw.o: In function `boost::program_options::typed_value<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char>::xparse(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) const':
/usr/include/boost/program_options/detail/value_semantic.hpp:184: undefined reference to `boost::program_options::validate(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, int)'
collect2: error: ld returned 1 exit status
Versions and OS
I am using: Ubuntu 18.04.3 LTS
gcc version: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
g++ version: g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
libboost version: Version: 1.65.1.0ubuntu1
Environment variables
I have set LD_LIBRARY_PATH to /usr/local/lib. This is where log4cplus libraries have been built.
I apologise if this question is not clear. Please let me know if that is the case so I can improve my question. If anyone can, please add the tag 'concord' to the question.
This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 5 years ago.
I am trying to use program_options from Boost in my project.
I am using Windows 10 but compiling on the ubuntu subsystem using g++.
I installed on boost using sudo apt install libboost-all-dev and then proceeded to try out their example file found here.
Then I compiled using g++ first.cpp and received the following error:
/tmp/cc9iLK5U.o: In function `main':
first.cpp:(.text+0x2e): undefined reference to `boost::program_options::options_description::m_default_line_length'
first.cpp:(.text+0x3a): undefined reference to `boost::program_options::options_description::m_default_line_length'
first.cpp:(.text+0x80): undefined reference to `boost::program_options::options_description::options_description(std::__cxx11::basic_string<char, std::char_traits<char>, std::allo
cator<char> > const&, unsigned int, unsigned int)'
first.cpp:(.text+0xb5): undefined reference to `boost::program_options::options_description::add_options()'
first.cpp:(.text+0xd5): undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, char const*)'
first.cpp:(.text+0xea): undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char
const*)'
first.cpp:(.text+0xf9): undefined reference to `boost::program_options::variables_map::variables_map()'
first.cpp:(.text+0x159): undefined reference to `boost::program_options::store(boost::program_options::basic_parsed_options<char> const&, boost::program_options::variables_map&, b
ool)'
first.cpp:(.text+0x186): undefined reference to `boost::program_options::notify(boost::program_options::variables_map&)'
first.cpp:(.text+0x20b): undefined reference to `boost::program_options::operator<<(std::ostream&, boost::program_options::options_description const&)'
/tmp/cc9iLK5U.o: In function `boost::program_options::error_with_option_name::~error_with_option_name()':
first.cpp:(.text._ZN5boost15program_options22error_with_option_nameD2Ev[_ZN5boost15program_options22error_with_option_nameD5Ev]+0x10): undefined reference to `vtable for boost::pr
ogram_options::error_with_option_name'
/tmp/cc9iLK5U.o: In function `boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::__cxx11::basic_string<char, std::ch
ar_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
first.cpp:(.text._ZN5boost15program_options16validation_errorC2ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i[_ZN5boost15program_options16validation_error
C5ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i]+0x3d): undefined reference to `boost::program_options::validation_error::get_template[abi:cxx11](boost::
program_options::validation_error::kind_t)'
first.cpp:(.text._ZN5boost15program_options16validation_errorC2ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i[_ZN5boost15program_options16validation_error
C5ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i]+0x5b): undefined reference to `boost::program_options::error_with_option_name::error_with_option_name(st
d::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::
__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/tmp/cc9iLK5U.o: In function `boost::program_options::value_semantic_codecvt_helper<char>::value_semantic_codecvt_helper()':
first.cpp:(.text._ZN5boost15program_options29value_semantic_codecvt_helperIcEC2Ev[_ZN5boost15program_options29value_semantic_codecvt_helperIcEC5Ev]+0x19): undefined reference to `
vtable for boost::program_options::value_semantic_codecvt_helper<char>'
/tmp/cc9iLK5U.o: In function `boost::program_options::value_semantic_codecvt_helper<char>::~value_semantic_codecvt_helper()':
first.cpp:(.text._ZN5boost15program_options29value_semantic_codecvt_helperIcED2Ev[_ZN5boost15program_options29value_semantic_codecvt_helperIcED5Ev]+0xd): undefined reference to `v
table for boost::program_options::value_semantic_codecvt_helper<char>'
/tmp/cc9iLK5U.o: In function `boost::program_options::variables_map::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const':
first.cpp:(.text._ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112ba
sic_stringIcSt11char_traitsIcESaIcEEE]+0x1f): undefined reference to `boost::program_options::abstract_variables_map::operator[](std::__cxx11::basic_string<char, std::char_traits<
char>, std::allocator<char> > const&) const'
/tmp/cc9iLK5U.o: In function `boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, char const* const*)':
first.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcEC2EiPKPKc[_ZN5boost15program_options25basic_command_line_parserIcEC5EiPKPKc]+0x81): undefined reference to
`boost::program_options::detail::cmdline::cmdline(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_
string<char, std::char_traits<char>, std::allocator<char> > > > const&)'
/tmp/cc9iLK5U.o: In function `boost::program_options::basic_command_line_parser<char>::options(boost::program_options::options_description const&)':
first.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcE7optionsERKNS0_19options_descriptionE[_ZN5boost15program_options25basic_command_line_parserIcE7optionsERKN
S0_19options_descriptionE]+0x1f): undefined reference to `boost::program_options::detail::cmdline::set_options_description(boost::program_options::options_description const&)'
/tmp/cc9iLK5U.o: In function `boost::program_options::basic_command_line_parser<char>::style(int)':
first.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcE5styleEi[_ZN5boost15program_options25basic_command_line_parserIcE5styleEi]+0x1c): undefined reference to `
boost::program_options::detail::cmdline::style(int)'
/tmp/cc9iLK5U.o: In function `boost::program_options::basic_command_line_parser<char>::extra_parser(boost::function1<std::pair<std::__cxx11::basic_string<char, std::char_traits<ch
ar>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__cxx11::basic_string<char, std::char_traits<char>, std::alloc
ator<char> > const&>)':
first.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcE12extra_parserENS_9function1ISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_ERKSA_EE[_ZN5b
oost15program_options25basic_command_line_parserIcE12extra_parserENS_9function1ISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_ERKSA_EE]+0x42): undefined reference
to `boost::program_options::detail::cmdline::set_additional_parser(boost::function1<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std
::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>)'
/tmp/cc9iLK5U.o: In function `boost::program_options::basic_command_line_parser<char>::run()':
first.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcE3runEv[_ZN5boost15program_options25basic_command_line_parserIcE3runEv]+0x28): undefined reference to `boos
t::program_options::detail::cmdline::get_canonical_option_prefix()'
first.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcE3runEv[_ZN5boost15program_options25basic_command_line_parserIcE3runEv]+0x54): undefined reference to `boos
t::program_options::detail::cmdline::run()'
/tmp/cc9iLK5U.o: In function `std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::cha
r_traits<char>, std::allocator<char> > > > boost::program_options::to_internal<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::vector<std::_
_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const
&)':
first.cpp:(.text._ZN5boost15program_options11to_internalINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEESt6vectorIS7_SaIS7_EERKS8_IT_SaISB_EE[_ZN5boost15program_options11to
_internalINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEESt6vectorIS7_SaIS7_EERKS8_IT_SaISB_EE]+0x6c): undefined reference to `boost::program_options::to_internal(std::__cx
x11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost15program_options11typed_valueIdcEE[_ZTVN5boost15program_options11typed_valueIdcEE]+0x38): undefined reference to `boost::program_options::valu
e_semantic_codecvt_helper<char>::parse(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic
_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool) const'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost15program_options20invalid_option_valueE[_ZTVN5boost15program_options20invalid_option_valueE]+0x20): undefined reference to `boost::program_opt
ions::error_with_option_name::what() const'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost15program_options20invalid_option_valueE[_ZTVN5boost15program_options20invalid_option_valueE]+0x30): undefined reference to `boost::program_opt
ions::error_with_option_name::substitute_placeholders(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost15program_options16validation_errorE[_ZTVN5boost15program_options16validation_errorE]+0x20): undefined reference to `boost::program_options::er
ror_with_option_name::what() const'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost15program_options16validation_errorE[_ZTVN5boost15program_options16validation_errorE]+0x30): undefined reference to `boost::program_options::er
ror_with_option_name::substitute_placeholders(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/tmp/cc9iLK5U.o:(.rodata._ZTIN5boost15program_options11typed_valueIdcEE[_ZTIN5boost15program_options11typed_valueIdcEE]+0x18): undefined reference to `typeinfo for boost::program_
options::value_semantic_codecvt_helper<char>'
/tmp/cc9iLK5U.o:(.rodata._ZTIN5boost15program_options16validation_errorE[_ZTIN5boost15program_options16validation_errorE]+0x10): undefined reference to `typeinfo for boost::progra
m_options::error_with_option_name'
/tmp/cc9iLK5U.o: In function `boost::program_options::variables_map::~variables_map()':
first.cpp:(.text._ZN5boost15program_options13variables_mapD2Ev[_ZN5boost15program_options13variables_mapD5Ev]+0xe): undefined reference to `vtable for boost::program_options::vari
ables_map'
/tmp/cc9iLK5U.o: In function `boost::program_options::typed_value<double, char>::name() const':
first.cpp:(.text._ZNK5boost15program_options11typed_valueIdcE4nameEv[_ZNK5boost15program_options11typed_valueIdcE4nameEv]+0x41): undefined reference to `boost::program_options::ar
g[abi:cxx11]'
/tmp/cc9iLK5U.o: In function `void boost::program_options::validate<double, char>(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<
char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, double*, long)':
first.cpp:(.text._ZN5boost15program_options8validateIdcEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l[_ZN5boost15program_options8va
lidateIdcEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l]+0x44): undefined reference to `boost::program_options::validators::check_f
irst_occurrence(boost::any const&)'
first.cpp:(.text._ZN5boost15program_options8validateIdcEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l[_ZN5boost15program_options8va
lidateIdcEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l]+0x141): undefined reference to `boost::program_options::invalid_option_val
ue::invalid_option_value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/cc9iLK5U.o: In function `boost::program_options::error_with_option_name::error_with_option_name(boost::program_options::error_with_option_name const&)':
first.cpp:(.text._ZN5boost15program_options22error_with_option_nameC2ERKS1_[_ZN5boost15program_options22error_with_option_nameC5ERKS1_]+0x25): undefined reference to `vtable for b
oost::program_options::error_with_option_name'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options16validation_errorEEEEE[_ZTVN5boost16exception_detail10clone_implI
NS0_19error_info_injectorINS_15program_options16validation_errorEEEEE]+0x28): undefined reference to `boost::program_options::error_with_option_name::what() const'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options16validation_errorEEEEE[_ZTVN5boost16exception_detail10clone_implI
NS0_19error_info_injectorINS_15program_options16validation_errorEEEEE]+0x38): undefined reference to `boost::program_options::error_with_option_name::substitute_placeholders(std::
__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options16validation_errorEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15progr
am_options16validation_errorEEE]+0x20): undefined reference to `boost::program_options::error_with_option_name::what() const'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options16validation_errorEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15progr
am_options16validation_errorEEE]+0x30): undefined reference to `boost::program_options::error_with_option_name::substitute_placeholders(std::__cxx11::basic_string<char, std::char_
traits<char>, std::allocator<char> > const&) const'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE[_ZTVN5boost16exception_detail10clone_i
mplINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE]+0x28): undefined reference to `boost::program_options::error_with_option_name::what() const'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE[_ZTVN5boost16exception_detail10clone_i
mplINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE]+0x38): undefined reference to `boost::program_options::error_with_option_name::substitute_placeholde
rs(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15p
rogram_options20invalid_option_valueEEE]+0x20): undefined reference to `boost::program_options::error_with_option_name::what() const'
/tmp/cc9iLK5U.o:(.rodata._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15p
rogram_options20invalid_option_valueEEE]+0x30): undefined reference to `boost::program_options::error_with_option_name::substitute_placeholders(std::__cxx11::basic_string<char, st
d::char_traits<char>, std::allocator<char> > const&) const'
collect2: error: ld returned 1 exit status
I am not sure if I missed a step or is it something related to WSL it self.
Turns out the problem is not related to WSL. I just had to add the appropriate links:
c++ first.cpp -lboost_program_options
I'm trying to build a program with some external/3rd party dependencies, but I keep getting undefined reference errors to functions/objects that I'm sure are being linked:
g++ -m64 -pthread -ljpeg -lrt -s -o build/release/darwin_socket build/release/main.o build/release/DarwinRobot.o build/release/dyn_system.o build/release/writefilestuff.o -lCppController /usr/local/webots/resources/projects/robots/darwin-op/libraries/darwin/libdarwin.so ../../lib/OPKinematics/lib/libOPKinematics64.a -lpthread -lipsocket -lboost_system -lboost_serialization -lm -L"/usr/local/webots/lib" -lController -lCppController
build/release/DarwinRobot.o: In function `webots::DarwinRobot::DarwinRobot()':
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:63: undefined reference to `webots::Robot::getLED(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:65: undefined reference to `webots::Robot::getLED(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:72: undefined reference to `webots::Robot::getGyro(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:75: undefined reference to `webots::Robot::getAccelerometer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:78: undefined reference to `webots::Robot::getServo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:80: undefined reference to `webots::Robot::getServo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:88: undefined reference to `webots::Robot::getServo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:90: undefined reference to `webots::Robot::getServo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:101: undefined reference to `webots::Robot::getServo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
build/release/DarwinRobot.o:/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:103: more undefined references to `webots::Robot::getServo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' follow
build/release/DarwinRobot.o: In function `webots::DarwinRobot::DarwinRobot()':
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:118: undefined reference to `webots::Robot::getTouchSensor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:120: undefined reference to `webots::Robot::getTouchSensor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:139: undefined reference to `webots::Robot::getTouchSensor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:141: undefined reference to `webots::Robot::getTouchSensor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
build/release/DarwinRobot.o: In function `webots::DarwinRobot::savePosition()':
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:170: undefined reference to `webots::Supervisor::getFromDef(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:170: undefined reference to `webots::Node::getField(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:171: undefined reference to `webots::Supervisor::getFromDef(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:171: undefined reference to `webots::Node::getField(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:173: undefined reference to `webots::Supervisor::getFromDef(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o: In function `webots::DarwinRobot::checkFall()':
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:1007: undefined reference to `webots::Supervisor::getFromDef(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/home/code/cpp/darwin/controllers/darwin_socket/src/DarwinRobot.cpp:1007: undefined reference to `webots::Supervisor::getFromDef(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0x48): undefined reference to `webots::Robot::createAccelerometer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0x50): undefined reference to `webots::Robot::createCamera(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0x58): undefined reference to `webots::Robot::createCompass(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0x60): undefined reference to `webots::Robot::createConnector(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0x68): undefined reference to `webots::Robot::createDisplay(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0x70): undefined reference to `webots::Robot::createDistanceSensor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0x78): undefined reference to `webots::Robot::createEmitter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0x80): undefined reference to `webots::Robot::createGPS(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0x88): undefined reference to `webots::Robot::createGyro(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0x90): undefined reference to `webots::Robot::createInertialUnit(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0x98): undefined reference to `webots::Robot::createLED(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0xa0): undefined reference to `webots::Robot::createLightSensor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0xa8): undefined reference to `webots::Robot::createMotor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0xb0): undefined reference to `webots::Robot::createPen(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0xb8): undefined reference to `webots::Robot::createPositionSensor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0xc0): undefined reference to `webots::Robot::createReceiver(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0xc8): undefined reference to `webots::Robot::createServo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0xd0): undefined reference to `webots::Robot::createTouchSensor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0xf0): undefined reference to `webots::Supervisor::startMovie(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, int, int, int, bool)'
build/release/DarwinRobot.o:(.rodata._ZTVN6webots11DarwinRobotE[_ZTVN6webots11DarwinRobotE]+0x100): undefined reference to `webots::Supervisor::setLabel(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double, double, double, int, double)'
collect2: error: ld returned 1 exit status
make: *** [/usr/local/webots/resources/Makefile.include:530: build/release/darwin_socket] Error 1
I'm particularly sure that these objects are defined in libCppController.so, called by the flag -lCppController. Manually checking the shared object file (e.g. 'LED'):
objdump -TC lib/libCppController.so | grep LED
0000000000021a8c g DF .text 0000000000000053 Base webots::Robot::createLED(std::string const&) const
00000000000225c6 w DF .text 0000000000000037 Base webots::LED::LED(std::string const&)
00000000000219da g DF .text 00000000000000b2 Base webots::Robot::getLED(std::string const&)
000000000001e074 g DF .text 000000000000002c Base webots::LED::set(int)
00000000000225c6 w DF .text 0000000000000037 Base webots::LED::LED(std::string const&)
000000000001e0a0 g DF .text 0000000000000024 Base webots::LED::get() const
0000000000024018 w DO .rodata 000000000000000e Base typeinfo name for webots::LED
000000000022b650 w DO .data.rel.ro 0000000000000018 Base typeinfo for webots::LED
000000000001e106 w DF .text 0000000000000026 Base webots::LED::~LED()
000000000001e0c4 w DF .text 0000000000000041 Base webots::LED::~LED()
000000000001e0c4 w DF .text 0000000000000041 Base webots::LED::~LED()
000000000022b620 w DO .data.rel.ro 0000000000000028 Base vtable for webots::LED
So what exactly am I doing wrong here?
Windows 10 Anniversary Update came out a couple of months ago, and I'm trying out the new "Bash on Ubuntu on Windows" feature.
I used it to compile some of my previous projects (finished on a normal Ubuntu machine), and while most of them were successfully built, a few of them received multiple undefined reference to ... (std::__cxx11::... errors when building the entire project (after compilations on separate files are done without errors).
I tried switching to g++-4.8, g++-4.9, g++-5.4 and g++-6.2 and all of them came down to the same result. I also tried adding compiler option -D_GLIBCXX_USE_CXX11_ABI=0/-D_GLIBCXX_USE_CXX11_ABI=1 in Makefile and still ended up with the same errors.
Here are parts of these error messages:
> building cirTest...
../../lib/libcmd.a(cmdCommon.o): In function `HistoryCmd::exec(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
cmdCommon.cpp:(.text+0xb3): undefined reference to `myStr2Int(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int&)'
../../lib/libcmd.a(cmdCommon.o): In function `HelpCmd::exec(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
cmdCommon.cpp:(.text+0x91d): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
../../lib/libcmd.a(cmdCommon.o): In function `UsageCmd::exec(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
cmdCommon.cpp:(.text+0xd5c): undefined reference to `myStrNCmp(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'
cmdCommon.cpp:(.text+0xdb9): undefined reference to `myStrNCmp(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'
cmdCommon.cpp:(.text+0xe68): undefined reference to `myStrNCmp(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'
../../lib/libcmd.a(cmdCommon.o): In function `QuitCmd::exec(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
cmdCommon.cpp:(.text+0x1190): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_first_not_of(char, unsigned long) const'
cmdCommon.cpp:(.text+0x126f): undefined reference to `myStrNCmp(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'
cmdCommon.cpp:(.text+0x1320): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Since most of my projects did build successfully, I wonder if it's possible to solve the problem by toggling some settings without jumping to the conclusion that this is simply a result of "Bash on Ubuntu on Windows" still being a "beta" feature.