C++ antlr4 with cmake not linking properly - c++

I'm trying to use the conan package manager with cmake to use antlr4.
my includes in main.cpp
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <cxxopts.hpp>
#include <filesystem>
#include <antlr4-runtime/antlr4-runtime.h>
#include "lexer/CrocLexer.h"
my CMakeLists.txt
cmake_minimum_required(VERSION 3.16.3)
project(crocc)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(crocc main.cpp lexer/CrocLexer.cpp)
set_target_properties(crocc PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)
target_link_libraries(crocc ${CONAN_LIBS})
and the error
[ 33%] Building CXX object CMakeFiles/crocc.dir/lexer/CrocLexer.cpp.o
[ 66%] Linking CXX executable bin/crocc
/usr/bin/ld: CMakeFiles/crocc.dir/lexer/CrocLexer.cpp.o: in function `(anonymous namespace)::CrocLexerStaticData::CrocLexerStaticData(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> > > >, 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> > > >, 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> > > >, 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> > > >, 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> > > >)':
CrocLexer.cpp:(.text+0x15e): undefined reference to `antlr4::dfa::Vocabulary::Vocabulary(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> > > >, 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> > > >)'
/usr/bin/ld: CMakeFiles/crocc.dir/lexer/CrocLexer.cpp.o:(.data.rel.ro._ZTV9CrocLexer[_ZTV9CrocLexer]+0x38): undefined reference to `antlr4::Recognizer::getRuleIndexMap[abi:cxx11]()'
/usr/bin/ld: CMakeFiles/crocc.dir/lexer/CrocLexer.cpp.o:(.data.rel.ro._ZTV9CrocLexer[_ZTV9CrocLexer]+0x58): undefined reference to `antlr4::Recognizer::getErrorHeader[abi:cxx11](antlr4::RecognitionException*)'
/usr/bin/ld: CMakeFiles/crocc.dir/lexer/CrocLexer.cpp.o:(.data.rel.ro._ZTV9CrocLexer[_ZTV9CrocLexer]+0x60): undefined reference to `antlr4::Recognizer::getTokenErrorDisplay[abi:cxx11](antlr4::Token*)'
/usr/bin/ld: CMakeFiles/crocc.dir/lexer/CrocLexer.cpp.o:(.data.rel.ro._ZTV9CrocLexer[_ZTV9CrocLexer]+0xf8): undefined reference to `antlr4::Lexer::getSourceName[abi:cxx11]()'
/usr/bin/ld: CMakeFiles/crocc.dir/lexer/CrocLexer.cpp.o:(.data.rel.ro._ZTV9CrocLexer[_ZTV9CrocLexer]+0x140): undefined reference to `antlr4::Lexer::getText[abi:cxx11]()'
/usr/bin/ld: CMakeFiles/crocc.dir/lexer/CrocLexer.cpp.o:(.data.rel.ro._ZTV9CrocLexer[_ZTV9CrocLexer]+0x148): undefined reference to `antlr4::Lexer::setText(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: CMakeFiles/crocc.dir/lexer/CrocLexer.cpp.o:(.data.rel.ro._ZTV9CrocLexer[_ZTV9CrocLexer]+0x1a8): undefined reference to `antlr4::Lexer::getErrorDisplay(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: CMakeFiles/crocc.dir/lexer/CrocLexer.cpp.o:(.data.rel.ro._ZTV9CrocLexer[_ZTV9CrocLexer]+0x200): undefined reference to `non-virtual thunk to antlr4::Lexer::getSourceName[abi:cxx11]()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/crocc.dir/build.make:99: bin/crocc] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/crocc.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
why is this happening? what did I do wrong?
Best regards

Related

faild to link protobuf

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
)

Boost Linking problems

I have tried to link boost in my CMakeList file by
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_NO_SYSTEM_PATHS TRUE)
set(Boost_INCLUDE_DIR /user/software/boost/boost-1.69-x86_64-cc7/include)
set(Boost_LIBRARY_DIR /user/software/boost/boost-1.69-x86_64-cc7/lib)
find_package(Boost 1.54 REQUIRED COMPONENTS filesystem program_options system)
and i get the following warning when doing cmake
CMake Warning at /user/software/cmake/cmake-3.7.1-x86_64-cc7/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
Imported targets not available for Boost version 106900
Call Stack (most recent call first):
/user/software/cmake/cmake-3.7.1-x86_64-cc7/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
/user/software/cmake/cmake-3.7.1-x86_64-cc7/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
util/src/CMakeLists.txt:21 (find_package)
So when i do the make command i get the error
CMakeFiles/checkFile.dir/checkFile.cpp.o: In function `boost::program_options::typed_value<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> > > >, char>::name() const':
checkFile.cpp:(.text._ZNK5boost15program_options11typed_valueISt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EEcE4nameEv[_ZNK5boost15program_options11typed_valueISt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EEcE4nameEv]+0x25): undefined reference to `boost::program_options::arg[abi:cxx11]'
CMakeFiles/checkFile.dir/checkFile.cpp.o: In function `boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, char const* const*)':
checkFile.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcEC2EiPKPKc[_ZN5boost15program_options25basic_command_line_parserIcEC5EiPKPKc]+0x112): undefined reference to `boost::program_options::to_internal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
checkFile.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcEC2EiPKPKc[_ZN5boost15program_options25basic_command_line_parserIcEC5EiPKPKc]+0x187): 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&)'
CMakeFiles/checkFile.dir/checkFile.cpp.o: In function `main':
checkFile.cpp:(.text.startup+0x63): undefined reference to `boost::program_options::options_description::options_description(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int)'
checkFile.cpp:(.text.startup+0x222): undefined reference to `boost::program_options::abstract_variables_map::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
CMakeFiles/checkFile.dir/checkFile.cpp.o: In function `void boost::program_options::validate<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 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&, 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> > > >*, int) [clone .constprop.475]':
checkFile.cpp:(.text._ZN5boost15program_options8validateINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEEvRNS_3anyERKSt6vectorINS3_IT0_S4_ISB_ESaISB_EEESaISE_EEPSA_IT_SaISJ_EEi.constprop.475[_ZNK5boost15program_options11typed_valueISt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EEcE6xparseERNS_3anyERKSA_]+0xc9): 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)'
checkFile.cpp:(.text._ZN5boost15program_options8validateINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEEvRNS_3anyERKSt6vectorINS3_IT0_S4_ISB_ESaISB_EEESaISE_EEPSA_IT_SaISJ_EEi.constprop.475[_ZNK5boost15program_options11typed_valueISt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EEcE6xparseERNS_3anyERKSA_]+0x4b4): undefined reference to `boost::program_options::invalid_option_value::invalid_option_value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
CMakeFiles/checkFile.dir/checkFile.cpp.o:(.data.rel.ro._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE]+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'
CMakeFiles/checkFile.dir/checkFile.cpp.o:(.data.rel.ro._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE]+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'
CMakeFiles/checkFile.dir/checkFile.cpp.o:(.data.rel.ro._ZTCN5boost10wrapexceptINS_15program_options20invalid_option_valueEEE0_NS_16exception_detail10clone_implINS4_19error_info_injectorIS2_EEEE[_ZTVN5boost10wrapexceptINS_15program_options20invalid_option_valueEEE]+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'
CMakeFiles/checkFile.dir/checkFile.cpp.o:(.data.rel.ro._ZTVN5boost10wrapexceptINS_15program_options20invalid_option_valueEEE[_ZTVN5boost10wrapexceptINS_15program_options20invalid_option_valueEEE]+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'
CMakeFiles/checkFile.dir/checkFile.cpp.o:(.data.rel.ro._ZTVN5boost15program_options16validation_errorE[_ZTVN5boost15program_options16validation_errorE]+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'
CMakeFiles/checkFile.dir/checkFile.cpp.o:(.data.rel.ro._ZTVN5boost15program_options20invalid_option_valueE[_ZTVN5boost15program_options20invalid_option_valueE]+0x30): more undefined references to `boost::program_options::error_with_option_name::substitute_placeholders(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const' follow
CMakeFiles/checkFile.dir/checkFile.cpp.o:(.data.rel.ro._ZTVN5boost15program_options11typed_valueISt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EEcEE[_ZTVN5boost15program_options11typed_valueISt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EEcEE]+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'
Any help please would be greatly appreciated
Try compiling your code while defining macro _GLIBCXX_USE_CXX11_ABI=0, e.g.:
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
If you get linker errors about undefined references to symbols that involve types in the std::__cxx11 namespace or the tag [abi:cxx11] then it probably indicates that you are trying to link together object files that were compiled with different values for the _GLIBCXX_USE_CXX11_ABI macro. This commonly happens when linking to a third-party library that was compiled with an older version of GCC. If the third-party library cannot be rebuilt with the new ABI then you will need to recompile your code with the old ABI.

Boost Program Options : linking error

I am having errors while compiling my C++ code on the server.
So on this particular server the standard g++ installed is version 4.4.6, which I cannot use for my program since I need -std=c++14.
So I use a different version, which is installed in the home directory of another user, which is a version 7.1, called with command g++_71.
Know all the files compile except one class where I make use of the boost program_options.
When just linking to -lboost_program_options, it wouldn't work, because it would link to an old version of boost, that does not support the functionalities I was using, and also was compiled with the 4.4.6 gcc.
Therefore I downloaded boost version 1.66.0 and installed it in my home directory in a folder I named boost. I made sure that boost was installed with the correct toolset g++_71, even if this should not change a thing for a header-only library which program_options is.
Now I still get linker errors :
objlinux/src/Utilities/Options/OptionsParser.o: In function `OptionsParser::parseOptionsFromCommandline(int, char**)':
OptionsParser.cpp:(.text+0x28c2): undefined reference to `boost::program_options::options_description::options_description(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int)'
objlinux/src/Utilities/Options/OptionsParser.o: In function `boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, 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)':
OptionsParser.cpp:(.text._ZN5boost15program_options16validation_errorC2ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i[_ZN5boost15program_options16validation_errorC5ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i]+0x21): undefined reference to `_ZN5boost15program_options16validation_error12get_templateB5cxx11ENS1_6kind_tE'
OptionsParser.cpp:(.text._ZN5boost15program_options16validation_errorC2ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i[_ZN5boost15program_options16validation_errorC5ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i]+0x3b): undefined reference to `boost::program_options::error_with_option_name::error_with_option_name(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&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
objlinux/src/Utilities/Options/OptionsParser.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':
OptionsParser.cpp:(.text._ZNK5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcE6xparseERNS_3anyERKSt6vectorIS7_SaIS7_EE[_ZNK5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcE6xparseERNS_3anyERKSt6vectorIS7_SaIS7_EE]+0x17): 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)'
objlinux/src/Utilities/Options/OptionsParser.o: In function `boost::program_options::typed_value<bool, 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':
OptionsParser.cpp:(.text._ZNK5boost15program_options11typed_valueIbcE6xparseERNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISB_EE[_ZNK5boost15program_options11typed_valueIbcE6xparseERNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISB_EE]+0x17): 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&, bool*, int)'
objlinux/src/Utilities/Options/OptionsParser.o: In function `boost::program_options::error_with_option_name::~error_with_option_name()':
OptionsParser.cpp:(.text._ZN5boost15program_options22error_with_option_nameD2Ev[_ZN5boost15program_options22error_with_option_nameD5Ev]+0x17): undefined reference to `vtable for boost::program_options::error_with_option_name'
objlinux/src/Utilities/Options/OptionsParser.o: In function `boost::program_options::error_with_option_name::error_with_option_name(boost::program_options::error_with_option_name const&)':
OptionsParser.cpp:(.text._ZN5boost15program_options22error_with_option_nameC2ERKS1_[_ZN5boost15program_options22error_with_option_nameC5ERKS1_]+0x22): undefined reference to `vtable for boost::program_options::error_with_option_name'
objlinux/src/Utilities/Options/OptionsParser.o: In function `boost::program_options::basic_command_line_parser<char>::run()':
OptionsParser.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcE3runEv[_ZN5boost15program_options25basic_command_line_parserIcE3runEv]+0x1b): undefined reference to `boost::program_options::detail::cmdline::get_canonical_option_prefix()'
objlinux/src/Utilities/Options/OptionsParser.o: In function `boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, char const* const*)':
OptionsParser.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcEC2EiPKPKc[_ZN5boost15program_options25basic_command_line_parserIcEC5EiPKPKc]+0x14d): undefined reference to `boost::program_options::to_internal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
OptionsParser.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcEC2EiPKPKc[_ZN5boost15program_options25basic_command_line_parserIcEC5EiPKPKc]+0x1e9): 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&)'
objlinux/src/Utilities/Options/OptionsParser.o: In function `boost::program_options::basic_parsed_options<char> boost::program_options::parse_command_line<char>(int, char const* const*, boost::program_options::options_description const&, int, 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&>)':
OptionsParser.cpp:(.text._ZN5boost15program_options18parse_command_lineIcEENS0_20basic_parsed_optionsIT_EEiPKPKS3_RKNS0_19options_descriptionEiNS_9function1ISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESJ_ERKSJ_EE[_ZN5boost15program_options18parse_command_lineIcEENS0_20basic_parsed_optionsIT_EEiPKPKS3_RKNS0_19options_descriptionEiNS_9function1ISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESJ_ERKSJ_EE]+0xaf): 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&>)'
objlinux/src/Utilities/Options/OptionsParser.o: In function `_ZNK5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcE4nameB5cxx11Ev':
OptionsParser.cpp:(.text._ZNK5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcE4nameEv[_ZNK5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcE4nameEv]+0x32): undefined reference to `_ZN5boost15program_options3argB5cxx11E'
objlinux/src/Utilities/Options/OptionsParser.o: In function `_ZNK5boost15program_options11typed_valueIlcE4nameB5cxx11Ev':
OptionsParser.cpp:(.text._ZNK5boost15program_options11typed_valueIlcE4nameB5cxx11Ev[_ZNK5boost15program_options11typed_valueIlcE4nameB5cxx11Ev]+0x32): undefined reference to `_ZN5boost15program_options3argB5cxx11E'
objlinux/src/Utilities/Options/OptionsParser.o: In function `_ZNK5boost15program_options11typed_valueIbcE4nameB5cxx11Ev':
OptionsParser.cpp:(.text._ZNK5boost15program_options11typed_valueIbcE4nameB5cxx11Ev[_ZNK5boost15program_options11typed_valueIbcE4nameB5cxx11Ev]+0x32): undefined reference to `_ZN5boost15program_options3argB5cxx11E'
objlinux/src/Utilities/Options/OptionsParser.o: In function `_ZNK5boost15program_options11typed_valueIdcE4nameB5cxx11Ev':
OptionsParser.cpp:(.text._ZNK5boost15program_options11typed_valueIdcE4nameB5cxx11Ev[_ZNK5boost15program_options11typed_valueIdcE4nameB5cxx11Ev]+0x32): undefined reference to `_ZN5boost15program_options3argB5cxx11E'
objlinux/src/Utilities/Options/OptionsParser.o: In function `_ZNK5boost15program_options11typed_valueIicE4nameB5cxx11Ev':
OptionsParser.cpp:(.text._ZNK5boost15program_options11typed_valueIicE4nameB5cxx11Ev[_ZNK5boost15program_options11typed_valueIicE4nameB5cxx11Ev]+0x32): undefined reference to `_ZN5boost15program_options3argB5cxx11E'
objlinux/src/Utilities/Options/OptionsParser.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)':
OptionsParser.cpp:(.text._ZN5boost15program_options8validateIdcEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l[_ZN5boost15program_options8validateIdcEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l]+0x4dd): undefined reference to `boost::program_options::invalid_option_value::invalid_option_value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
objlinux/src/Utilities/Options/OptionsParser.o: In function `void boost::program_options::validate<long, 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&, long*, long)':
OptionsParser.cpp:(.text._ZN5boost15program_options8validateIlcEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l[_ZN5boost15program_options8validateIlcEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l]+0x264): undefined reference to `boost::program_options::invalid_option_value::invalid_option_value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
objlinux/src/Utilities/Options/OptionsParser.o: In function `void boost::program_options::validate<int, 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&, int*, long)':
OptionsParser.cpp:(.text._ZN5boost15program_options8validateIicEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l[_ZN5boost15program_options8validateIicEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l]+0x233): undefined reference to `boost::program_options::invalid_option_value::invalid_option_value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE]+0x20): undefined reference to `boost::program_options::error_with_option_name::what() const'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE]+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'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE]+0x28): undefined reference to `boost::program_options::error_with_option_name::what() const'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE]+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'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options16validation_errorEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15program_options16validation_errorEEE]+0x20): undefined reference to `boost::program_options::error_with_option_name::what() const'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options16validation_errorEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15program_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'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options16validation_errorEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options16validation_errorEEEEE]+0x28): undefined reference to `boost::program_options::error_with_option_name::what() const'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options16validation_errorEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_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'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTIN5boost15program_options16validation_errorE[_ZTIN5boost15program_options16validation_errorE]+0x10): undefined reference to `typeinfo for boost::program_options::error_with_option_name'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost15program_options16validation_errorE[_ZTVN5boost15program_options16validation_errorE]+0x20): undefined reference to `boost::program_options::error_with_option_name::what() const'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost15program_options16validation_errorE[_ZTVN5boost15program_options16validation_errorE]+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'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost15program_options20invalid_option_valueE[_ZTVN5boost15program_options20invalid_option_valueE]+0x20): undefined reference to `boost::program_options::error_with_option_name::what() const'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost15program_options20invalid_option_valueE[_ZTVN5boost15program_options20invalid_option_valueE]+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'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._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'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost15program_options11typed_valueIicEE[_ZTVN5boost15program_options11typed_valueIicEE]+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'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost15program_options11typed_valueIlcEE[_ZTVN5boost15program_options11typed_valueIlcEE]+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'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost15program_options11typed_valueIdcEE[_ZTVN5boost15program_options11typed_valueIdcEE]+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'
objlinux/src/Utilities/Options/OptionsParser.o:(.rodata._ZTVN5boost15program_options11typed_valueIbcEE[_ZTVN5boost15program_options11typed_valueIbcEE]+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'
collect2: error: ld returned 1 exit status
make: *** [ACOPPD] Error 1
I tried different techniques to resolve this error:
I tried to just do the recommended include : #include "boost/program_options.hpp" and -I /home/mkupper/boost/boost_1_66_0 in the Makefile as it is recommended by the boost documentation for header-only library, which program_options is.
I tried to include with the full path : #include "/home/mkupper/boost/boost_1_66_0/boost/program_options.hpp"
I tried to include -I /home/mkupper/boost/boost_1_66_0 -L /home/mkupper/boost/boost_1_66_0/libs into the linker and compiler flags to.
I tried to include -lboost_program_options in addition to the other includes.
I tried if the -lstdc++ would change anything.
Nothing changes the linker errors, I am helpless !
Here my current Makefile:
CFLAGS := -std=c++14 -Wall -Ofast -march=native -Wunused-parameter
LDFLAGS := -lstdc++ -I /home/mkupper/boost/boost_1_66_0 -L /home/mkupper/boost/boost_1_66_0/libs
BUILDDIR := objlinux
SOURCEDIR := src
HEADERDIR := include
SRCEXT := cpp
OBJEXT := o
SOURCES := $(shell find $(SOURCEDIR) -name '*.$(SRCEXT)')
OBJECTS := $(addprefix $(BUILDDIR)/,$(SOURCES:%.$(SRCEXT)=%.$(OBJEXT)))
BINARY := ./ACOPPD
ECHO := echo
RM := rm -rf
MKDIR := mkdir
.PHONY: all clean
all: $(BINARY)
$(BINARY): $(OBJECTS)
g++_71 $(CFLAGS) $(OBJECTS) -o $(BINARY) $(LDFLAGS)
$(BUILDDIR)/%.$(OBJEXT): %.$(SRCEXT)
g++_71 $(CFLAGS) $(LDFLAGS) -I $(HEADERDIR) -I $(dir $<) -c $< -o $#
clean:
$(RM) $(BINARY) $(OBJECTS)
distclean: clean
The -I option indicates where the compiler needs to find the include files, therefore it belongs to the compiler flags CFLAGS.
The -L option indicates where the linker needs to find the library files, and the -l option tells the linker which libraries to include, therefore both should go into LDFLAGS.
With these said, you have missed the -lboost_program_options flag in LDFLAGS. As a result the linker will not incorporate the boost_program_options library. -L alone here is meaningless.
Bottom lines - try these:
CFLAGS := -std=c++14 -Wall -Ofast -march=native -Wunused-parameter -I/home/mkupper/boost/boost_1_66_0
LDFLAGS := -L/home/mkupper/boost/boost_1_66_0/libs -lstdc++ -lboost_program_options

cmake linker error "undefined reference to" How to properly link the libraries in cmake?

I have been smashing my head on my keyboard on this for hours and on similar problems for the last 3 days. I am new to cmake and trying to figure it out.
Basically i have a very simple program example for a library i am trying to use, and i am trying to make a cmake file to compile it and include all of its dependancies properly. It is day 3 and i am getting this linker error now though and i can't for the life of me figure out why.
This is what i have in my CMakeLists.txt:
cmake_minimum_required(VERSION 3.4)
if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
message( FATAL_ERROR "In-source builds not allowed. Please make a new directory and run CMake from there. You may need to remove CMakeCache.txt." )
endif()
set(PROJECT_NAME HelloWorldDiscordBot)
project(${PROJECT_NAME})
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin
CACHE PATH
"Single Directory for all"
)
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin
CACHE PATH
"Single Directory for all"
)
SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/lib
CACHE PATH
"Single Directory for all"
)
include_directories("/home/connor/Documents/yourWaifu-sleepy-discord/")
include_directories("/home/connor/projects/HelloWorldDiscordBot/deps/")
include_directories("/home/connor/projects/HelloWorldDiscordBot/deps/include/")
include_directories("/home/connor/projects/HelloWorldDiscordBot/deps/cpr/cpr/")
include_directories("/usr/local/openssl/include")
#include_directories("/usr/include")
#include_directories("/home/connor/Documents/yourWaifu-sleepy-discord/sleepy_discord/IncludeNonexistent/")
#include_directories("/home/connor/Documents/yourWaifu-sleepy-discord/sleepy_discord/IncludeNonexistent/websocketpp/config/")
#include_directories("/home/connor/projects/HelloWorldDiscordBot/deps/lib/")
set(HelloWorldDiscordBot_sources main.cpp)
add_executable(${PROJECT_NAME} ${HelloWorldDiscordBot_sources})
target_link_libraries(${PROJECT_NAME} ${PROJECT_SOURCE_DIR}/deps/lib/libssl.a
${PROJECT_SOURCE_DIR}/deps/lib/libcrypto.a
${PROJECT_SOURCE_DIR}/deps/lib/libsleepy_discord.a)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
The linker error's i'm getting:
/home/connor/projects/HelloWorldDiscordBot/build> make -j2
-- Configuring done
-- Generating done
-- Build files have been written to: /home/connor/projects/HelloWorldDiscordBot/build
[ 50%] Linking CXX executable bin/HelloWorldDiscordBot
../deps/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x11): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x24): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x2f): undefined reference to `dlclose'
../deps/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x334): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x3db): undefined reference to `dlerror'
../deps/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x454): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x4fb): undefined reference to `dlerror'
../deps/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x569): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x5cb): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x603): undefined reference to `dlerror'
../deps/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x69f): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x709): undefined reference to `dlerror'
../deps/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x762): undefined reference to `dlclose'
CMakeFiles/HelloWorldDiscordBot.dir/main.cpp.o: In function `main':
/home/connor/projects/HelloWorldDiscordBot/main.cpp:17: undefined reference to `SleepyDiscord::WebsocketppDiscordClient::run()'
CMakeFiles/HelloWorldDiscordBot.dir/main.cpp.o: In function `myClientClass::myClientClass(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char)':
/home/connor/projects/HelloWorldDiscordBot/main.cpp:8: undefined reference to `SleepyDiscord::WebsocketppDiscordClient::WebsocketppDiscordClient(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char)'
CMakeFiles/HelloWorldDiscordBot.dir/main.cpp.o: In function `myClientClass::~myClientClass()':
/home/connor/projects/HelloWorldDiscordBot/main.cpp:6: undefined reference to `SleepyDiscord::WebsocketppDiscordClient::~WebsocketppDiscordClient()'
CMakeFiles/HelloWorldDiscordBot.dir/main.cpp.o:(.rodata._ZTV13myClientClass[_ZTV13myClientClass]+0x10): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::run()'
CMakeFiles/HelloWorldDiscordBot.dir/main.cpp.o:(.rodata._ZTV13myClientClass[_ZTV13myClientClass]+0x1a0): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::sleep(unsigned int)'
CMakeFiles/HelloWorldDiscordBot.dir/main.cpp.o:(.rodata._ZTV13myClientClass[_ZTV13myClientClass]+0x1b8): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::onError(SleepyDiscord::ErrorCode, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
CMakeFiles/HelloWorldDiscordBot.dir/main.cpp.o:(.rodata._ZTV13myClientClass[_ZTV13myClientClass]+0x1c0): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
CMakeFiles/HelloWorldDiscordBot.dir/main.cpp.o:(.rodata._ZTV13myClientClass[_ZTV13myClientClass]+0x1c8): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::send(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
CMakeFiles/HelloWorldDiscordBot.dir/main.cpp.o:(.rodata._ZTV13myClientClass[_ZTV13myClientClass]+0x1d0): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::disconnect(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
CMakeFiles/HelloWorldDiscordBot.dir/main.cpp.o:(.rodata._ZTV13myClientClass[_ZTV13myClientClass]+0x1d8): undefined reference to `SleepyDiscord::WebsocketppDiscordClient::runAsync()'
CMakeFiles/HelloWorldDiscordBot.dir/main.cpp.o:(.rodata._ZTI13myClientClass[_ZTI13myClientClass]+0x10): undefined reference to `typeinfo for SleepyDiscord::WebsocketppDiscordClient'
../deps/lib/libsleepy_discord.a(client.cpp.o): In function `SleepyDiscord::CPRSession::setUrl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
client.cpp:(.text._ZN13SleepyDiscord10CPRSession6setUrlERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN13SleepyDiscord10CPRSession6setUrlERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x46): undefined reference to `cpr::Session::SetUrl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
../deps/lib/libsleepy_discord.a(client.cpp.o): In function `SleepyDiscord::CPRSession::setBody(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*)':
client.cpp:(.text._ZN13SleepyDiscord10CPRSession7setBodyEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN13SleepyDiscord10CPRSession7setBodyEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x46): undefined reference to `cpr::Session::SetBody(cpr::Body&&)'
../deps/lib/libsleepy_discord.a(client.cpp.o): In function `SleepyDiscord::CPRSession::Post()':
client.cpp:(.text._ZN13SleepyDiscord10CPRSession4PostEv[_ZN13SleepyDiscord10CPRSession4PostEv]+0x42): undefined reference to `cpr::Session::Post()'
../deps/lib/libsleepy_discord.a(client.cpp.o): In function `SleepyDiscord::CPRSession::Patch()':
client.cpp:(.text._ZN13SleepyDiscord10CPRSession5PatchEv[_ZN13SleepyDiscord10CPRSession5PatchEv]+0x42): undefined reference to `cpr::Session::Patch()'
../deps/lib/libsleepy_discord.a(client.cpp.o): In function `SleepyDiscord::CPRSession::Delete()':
client.cpp:(.text._ZN13SleepyDiscord10CPRSession6DeleteEv[_ZN13SleepyDiscord10CPRSession6DeleteEv]+0x42): undefined reference to `cpr::Session::Delete()'
../deps/lib/libsleepy_discord.a(client.cpp.o): In function `SleepyDiscord::CPRSession::Get()':
client.cpp:(.text._ZN13SleepyDiscord10CPRSession3GetEv[_ZN13SleepyDiscord10CPRSession3GetEv]+0x42): undefined reference to `cpr::Session::Get()'
../deps/lib/libsleepy_discord.a(client.cpp.o): In function `SleepyDiscord::CPRSession::Put()':
client.cpp:(.text._ZN13SleepyDiscord10CPRSession3PutEv[_ZN13SleepyDiscord10CPRSession3PutEv]+0x42): undefined reference to `cpr::Session::Put()'
../deps/lib/libsleepy_discord.a(client.cpp.o): In function `SleepyDiscord::CPRSession::CPRSession()':
client.cpp:(.text._ZN13SleepyDiscord10CPRSessionC2Ev[_ZN13SleepyDiscord10CPRSessionC5Ev]+0x30): undefined reference to `cpr::Session::Session()'
../deps/lib/libsleepy_discord.a(client.cpp.o): In function `SleepyDiscord::CPRSession::~CPRSession()':
client.cpp:(.text._ZN13SleepyDiscord10CPRSessionD2Ev[_ZN13SleepyDiscord10CPRSessionD5Ev]+0x24): undefined reference to `cpr::Session::~Session()'
../deps/lib/libsleepy_discord.a(client.cpp.o): In function `std::thread::thread<void (SleepyDiscord::BaseDiscordClient::*)(), SleepyDiscord::BaseDiscordClient*>(void (SleepyDiscord::BaseDiscordClient::*&&)(), SleepyDiscord::BaseDiscordClient*&&)':
client.cpp:(.text._ZNSt6threadC2IMN13SleepyDiscord17BaseDiscordClientEFvvEJPS2_EEEOT_DpOT0_[_ZNSt6threadC5IMN13SleepyDiscord17BaseDiscordClientEFvvEJPS2_EEEOT_DpOT0_]+0x93): undefined reference to `pthread_create'
../deps/lib/libsleepy_discord.a(cpr_session.cpp.o): In function `SleepyDiscord::CPRSession::setHeader(std::initializer_list<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> > > > const&)':
cpr_session.cpp:(.text+0xdd): undefined reference to `cpr::Session::SetHeader(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, cpr::CaseInsensitiveCompare, std::allocator<std::pair<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&)'
../deps/lib/libsleepy_discord.a(cpr_session.cpp.o): In function `SleepyDiscord::CPRSession::setMultipart(std::initializer_list<SleepyDiscord::Part> const&)':
cpr_session.cpp:(.text+0x346): undefined reference to `cpr::Multipart::Multipart(std::initializer_list<cpr::Part> const&)'
cpr_session.cpp:(.text+0x39d): undefined reference to `cpr::Session::SetMultipart(cpr::Multipart const&)'
../deps/lib/libsleepy_discord.a(cpr_session.cpp.o): In function `std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<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> > >, std::_Select1st<std::pair<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> > > >, cpr::CaseInsensitiveCompare, std::allocator<std::pair<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> > > > >::_M_get_insert_unique_pos(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
cpr_session.cpp:(.text._ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_EN3cpr22CaseInsensitiveCompareESaIS8_EE24_M_get_insert_unique_posERS7_[_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_EN3cpr22CaseInsensitiveCompareESaIS8_EE24_M_get_insert_unique_posERS7_]+0x72): undefined reference to `cpr::CaseInsensitiveCompare::operator()(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&) const'
cpr_session.cpp:(.text._ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_EN3cpr22CaseInsensitiveCompareESaIS8_EE24_M_get_insert_unique_posERS7_[_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_EN3cpr22CaseInsensitiveCompareESaIS8_EE24_M_get_insert_unique_posERS7_]+0x12a): undefined reference to `cpr::CaseInsensitiveCompare::operator()(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&) const'
../deps/lib/libsleepy_discord.a(cpr_session.cpp.o): In function `std::_Rb_tree_iterator<std::pair<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> > > > std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<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> > >, std::_Select1st<std::pair<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> > > >, cpr::CaseInsensitiveCompare, std::allocator<std::pair<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> > > > >::_M_insert_<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::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<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> > >, std::_Select1st<std::pair<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> > > >, cpr::CaseInsensitiveCompare, std::allocator<std::pair<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> > > > >::_Alloc_node>(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, 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::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<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> > >, std::_Select1st<std::pair<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> > > >, cpr::CaseInsensitiveCompare, std::allocator<std::pair<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> > > > >::_Alloc_node&)':
cpr_session.cpp:(.text._ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_EN3cpr22CaseInsensitiveCompareESaIS8_EE10_M_insert_IRS6_IS5_S5_ENSE_11_Alloc_nodeEEESt17_Rb_tree_iteratorIS8_EPSt18_Rb_tree_node_baseSM_OT_RT0_[_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_EN3cpr22CaseInsensitiveCompareESaIS8_EE10_M_insert_IRS6_IS5_S5_ENSE_11_Alloc_nodeEEESt17_Rb_tree_iteratorIS8_EPSt18_Rb_tree_node_baseSM_OT_RT0_]+0x84): undefined reference to `cpr::CaseInsensitiveCompare::operator()(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&) const'
collect2: error: ld returned 1 exit status
CMakeFiles/HelloWorldDiscordBot.dir/build.make:97: recipe for target 'bin/HelloWorldDiscordBot' failed
make[2]: *** [bin/HelloWorldDiscordBot] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/HelloWorldDiscordBot.dir/all' failed
make[1]: *** [CMakeFiles/HelloWorldDiscordBot.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
*** Failure: Exit code 2 ***
The structure of my project dependencies folder
Am i doing something wrong? I am pretty sure i have all of my dependencies in check, so i am wondering if i maybe did something dumb in my cmake file.

QuantLib linker error: QuantLib::Error::Error()

I am trying to get QL working on Debian, but failing at the last step. I have downloaded the source, built and installed the library (“make”, “make install”) without any errors, but my application that uses the QuantLib library throws up some linker errors related to a single class (QuantLib::Error):
build/Debug/GNU-Linux-x86/PricingEngine.o: In function `QuantLib::Observable::notifyObservers()':
/usr/local/include/ql/patterns/observable.hpp:143: undefined reference to `QuantLib::Error::Error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long, 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&)'
build/Debug/GNU-Linux-x86/PricingEngine.o: In function `QuantLib::operator+(QuantLib::Array const&, QuantLib::Array const&)':
/usr/local/include/ql/math/array.hpp:499: undefined reference to `QuantLib::Error::Error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long, 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&)'
build/Debug/GNU-Linux-x86/PricingEngine.o: In function `QuantLib::DiscretizedOption::reset(unsigned long)':
/usr/local/include/ql/discretizedasset.hpp:222: undefined reference to `QuantLib::Error::Error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long, 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&)'
build/Debug/GNU-Linux-x86/PricingEngine.o: In function `QuantLib::Instrument::setupArguments(QuantLib::PricingEngine::arguments*) const':
/usr/local/include/ql/instrument.hpp:145: undefined reference to `QuantLib::Error::Error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long, 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&)'
build/Debug/GNU-Linux-x86/PricingEngine.o: In function `QuantLib::Instrument::performCalculations() const':
/usr/local/include/ql/instrument.hpp:164: undefined reference to `QuantLib::Error::Error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long, 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&)'
build/Debug/GNU-Linux-x86/PricingEngine.o:/usr/local/include/ql/instrument.hpp:176: more undefined references to `QuantLib::Error::Error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long, 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&)' follow
I’m on Debian 8, amd64, compiled both the library and application with g++-5.
Does anyone have any ideas?
EDIT: Here's the command line:
g++ -o dist/Debug/GNU-Linux-x86/hub build/Debug/GNU-Linux-x86/Calculations.o build/Debug/GNU-Linux-x86/Client.o build/Debug/GNU-Linux-x86/Connection.o build/Debug/GNU-Linux-x86/DataStore.o build/Debug/GNU-Linux-x86/Hub.o build/Debug/GNU-Linux-x86/Instruments.o build/Debug/GNU-Linux-x86/Parameters.o build/Debug/GNU-Linux-x86/PricingEngine.o build/Debug/GNU-Linux-x86/Server.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/stdafx.o -L/usr/lib/x86_64-linux-gnu -L/usr/lib ../Core/dist/Debug/GNU-Linux-x86/libcore.a -lQuantLib /usr/lib/x86_64-linux-gnu/libboost_log.a /usr/lib/x86_64-linux-gnu/libboost_log_setup.a -lboost_system -lzmq -lboost_filesystem -lpq -lboost_unit_test_framework -lboost_thread -lpgm -lldap -lssl -lcrypto -lsodium -ldl -pthread
It is likely that PricingEngine.o is compiled with (default) value of _GLIBCXX_USE_CXX11_ABI=1, while QuantLib is compiled with _GLIBCXX_USE_CXX11_ABI=0.
See also example at the end of this answer.