I'm using CMAKE to build my project:
cmake_minimum_required(VERSION 3.14)
set (CMAKE_CXX_STANDARD 11)
project(saryxo_checker)
find_package( OpenCV REQUIRED )
find_package( Boost 1.71 REQUIRED COMPONENTS program_options filesystem system )
set(SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/src/main.cpp
${CMAKE_CURRENT_LIST_DIR}/src/FeatureEvaluator.cpp
${CMAKE_CURRENT_LIST_DIR}/src/Converter.cpp
${CMAKE_CURRENT_LIST_DIR}/core/util.cpp)
include_directories(
${CMAKE_CURRENT_LIST_DIR}/include
${CMAKE_CURRENT_LIST_DIR}/core
${OpenCV_INCLUDE_DIR}
${Boost_INCLUDE_DIR})
add_executable(saryxo_checker ${SOURCE_FILES})
target_link_libraries(saryxo_checker ${OpenCV_LIBS} ${Boost_LIBRARIES})
However, it throws an error during linking. The errors are thrown INSIDE of Boost.
[ 20%] Linking CXX executable saryxo_checker
CMakeFiles/saryxo_checker.dir/src/main.cpp.o: In Function »__static_initialization_and_destruction_0(int, int)«:
/usr/local/include/boost/system/error_code.hpp:221: Warning: undefined reference to »boost::system::generic_category()«
/usr/local/include/boost/system/error_code.hpp:222: Warning: undefined reference to »boost::system::generic_category()«
/usr/local/include/boost/system/error_code.hpp:223: Warning: undefined reference to »boost::system::system_category()«
CMakeFiles/saryxo_checker.dir/src/main.cpp.o: In function »boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, char const* const*)«:
/usr/local/include/boost/program_options/detail/parsers.hpp:44: Warning: undefined reference to »boost::program_options::detail::cmdline::cmdline(std::__debug::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/saryxo_checker.dir/src/main.cpp.o:(.data.rel.ro._ZTVN5boost15program_options11typed_valueIicEE[_ZTVN5boost15pro ram_options11typed_valueIicEE]+0x40): Warning: undefined reference to »boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::__debug::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«
CMakeFiles/keypoint_tracker_evaluator_saryxoS_Trian.dir/src/main.cpp.o:(.data.rel.ro._ZTVN5boost15program_options11typed_valueIjcEE[_ZTVN5boost15program_options11typed_valueIjcEE]+0x40): Warning: undefined reference to »boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::__debug::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«
CMakeFiles/saryxo_checker.dir/src/main.cpp.o:(.data.rel.ro._ZTVN5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEE[_ZTVN5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEE]+0x40): Warning: undefined reference to »boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::__debug::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«
CMakeFiles/saryxo_checker.dir/src/main.cpp.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::__debug::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) const«:
/usr/local/include/boost/program_options/detail/value_semantic.hpp:167: Warning: undefined reference to »boost::program_options::validate(boost::any&, std::__debug::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)«
CMakeFiles/saryxo_checker.dir/src/FeatureEvaluator.cpp.o: In function »__static_initialization_and_destruction_0(int, int)«:
/usr/local/include/boost/system/error_code.hpp:221: Warning: undefined reference to »boost::system::generic_category()«
/usr/local/include/boost/system/error_code.hpp:222: Warning: undefined reference to »boost::system::generic_category()«
/usr/local/include/boost/system/error_code.hpp:223: Warning: undefined reference to »boost::system::system_category()«
CMakeFiles/saryxo_checker.dir/src/Converter.cpp.o: In function »__static_initialization_and_destruction_0(int, int)«:
/usr/local/include/boost/system/error_code.hpp:221: Warning: undefined reference to »boost::system::generic_category()«
/usr/local/include/boost/system/error_code.hpp:222: Warning: undefined reference to »boost::system::generic_category()«
/usr/local/include/boost/system/error_code.hpp:223: Warning: undefined reference to »boost::system::system_category()«
CMakeFiles/saryxo_checker.dir/src/Converter.cpp.o: In function »boost::system::error_code::error_code()«:
/usr/local/include/boost/system/error_code.hpp:322: Warning: undefined reference to »boost::system::system_category()«
CMakeFiles/saryxo_checker.dir/src/Converter.cpp.o: In function »boost::system::error_code::clear()«:
/usr/local/include/boost/system/error_code.hpp:350: Warning: undefined reference to »boost::system::system_category()«
CMakeFiles/saryxo_checker.dir/core/util.cpp.o: In in function »__static_initialization_and_destruction_0(int, int)«:
/usr/local/include/boost/system/error_code.hpp:221: Warning: undefined reference to »boost::system::generic_category()«
/usr/local/include/boost/system/error_code.hpp:222: Warning: undefined reference to »boost::system::generic_category()«
/usr/local/include/boost/system/error_code.hpp:223: Warning: undefined reference to »boost::system::system_category()«
collect2: error: ld returned 1 exit status
CMakeFiles/saryxo_checker.dir/build.make:179: recipe for target 'saryxo_checker' failed
make[3]: *** [saryxo_checker] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/saryxo_checker.dir/all' failed
make[2]: *** [CMakeFiles/saryxo_checker.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/saryxo_checker.dir/rule' failed
make[1]: *** [CMakeFiles/saryxo_checker.dir/rule] Error 2
Makefile:118: recipe for target 'saryxo_checker' failed
make: *** [saryxo_checker] Error 2
I tried building boost in debug mode, as I build my program in debug mode as well, but the error stays the same. What could it be?
OS: Ubuntu 18.04
CMake: 3.14
Boost 1.71
Related
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
I am trying to import mysql connector to my c++ project but I am getting errors at the linking stage. This is my
CMakeLists.txt:
add_executable(app
src/main.cpp
)
add_library(mysql STATIC IMPORTED)
set_property(TARGET mysql PROPERTY
IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/src/mysql-connector/lib64/libmysqlcppconn8-static.a)
target_include_directories(
app
PRIVATE ${CMAKE_SOURCE_DIR}/src/mysql-connector/include
)
target_link_libraries(
app
PRIVATE mysql
PRIVATE crypto
PRIVATE ssl
PRIVATE rt
PRIVATE resolv
)
Here is the output from the compilation stage:
/usr/bin/ld: CMakeFiles/app.dir/src/main.cpp.o: in function `main':
/home/chris/app/src/main.cpp:122: undefined reference to `mysqlx::abi2::r0::DbDoc::Iterator::operator*[abi:cxx11]()'
/usr/bin/ld: /home/chris/app/src/main.cpp:124: undefined reference to `mysqlx::abi2::r0::DbDoc::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/usr/bin/ld: /home/chris/app/src/main.cpp:130: undefined reference to `mysqlx::abi2::r0::DbDoc::hasField(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/usr/bin/ld: /home/chris/app/src/main.cpp:134: undefined reference to `mysqlx::abi2::r0::DbDoc::Iterator::operator*[abi:cxx11]()'
/usr/bin/ld: /home/chris/app/src/main.cpp:136: undefined reference to `mysqlx::abi2::r0::DbDoc::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/usr/bin/ld: /home/chris/app/src/main.cpp:144: undefined reference to `mysqlx::abi2::r0::DbDoc::hasField(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/usr/bin/ld: CMakeFiles/app.dir/src/main.cpp.o: in function `mysqlx::abi2::r0::string::traits<char>::from_str(mysqlx::abi2::r0::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/chris/app/src/mysql-connector/include/mysqlx/devapi/common.h:220: undefined reference to `mysqlx::abi2::r0::string::Impl::from_utf8(mysqlx::abi2::r0::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: CMakeFiles/app.dir/src/main.cpp.o: in function `mysqlx::abi2::r0::string::traits<char>::to_str[abi:cxx11](mysqlx::abi2::r0::string const&)':
/home/chris/app/src/mysql-connector/include/mysqlx/devapi/common.h:225: undefined reference to `mysqlx::abi2::r0::string::Impl::to_utf8[abi:cxx11](mysqlx::abi2::r0::string const&)'
/usr/bin/ld: CMakeFiles/app.dir/src/main.cpp.o: in function `mysqlx::abi2::r0::string mysqlx::abi2::r0::Value::get<mysqlx::abi2::r0::string>() const':
/home/chris/app/src/mysql-connector/include/mysqlx/devapi/document.h:955: undefined reference to `mysqlx::abi2::r0::common::Value::get_ustring[abi:cxx11]() const'
/usr/bin/ld: CMakeFiles/app.dir/src/main.cpp.o: in function `mysqlx::abi2::r0::Value::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const':
/home/chris/app/src/mysql-connector/include/mysqlx/devapi/document.h:1013: undefined reference to `mysqlx::abi2::r0::DbDoc::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/usr/bin/ld: CMakeFiles/app.dir/src/main.cpp.o: in function `mysqlx::abi2::r0::Result::getGeneratedIds[abi:cxx11]() const':
/home/chris/app/src/mysql-connector/include/mysqlx/devapi/result.h:211: undefined reference to `mysqlx::abi2::r0::internal::Result_detail::get_generated_ids[abi:cxx11]() const'
/usr/bin/ld: CMakeFiles/app.dir/src/main.cpp.o: in function `mysqlx::abi2::r0::SessionSettings::SessionSettings(mysqlx::abi2::r0::string const&)':
/home/chris/app/src/mysql-connector/include/mysqlx/devapi/settings.h:526: undefined reference to `mysqlx::abi2::r0::common::Settings_impl::set_from_uri(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/app.dir/build.make:236: app] Error 1
make[1]: *** [CMakeFiles/Makefile2:449: CMakeFiles/app.dir/all] Error 2
make: *** [Makefile:171: all] Error 2
when importing #include <mysqlx/xdevapi.h> . Any help would be much appreciated.
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
)
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.
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.