QuantLib linker error: QuantLib::Error::Error() - c++

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.

Related

C++ antlr4 with cmake not linking properly

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

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.

Undefined reference to std::__cxx11:: errors (Bash on Ubuntu on Windows)

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.