JosephP91 / curlcpp

An object oriented C++ wrapper for CURL (libcurl)
https://josephp91.github.io/curlcpp
MIT License
630 stars 174 forks source link

Error while including CURLCPP with CMake #113

Closed stav121 closed 7 years ago

stav121 commented 7 years ago

Good evening,

I've included CURLCPP in my project but I'm facing a weird problem while I include it with CMake in my project:

[ 11%] Built target client [ 16%] Linking CXX executable server CMakeFiles/server.dir/source_code/server.cpp.o: In functioncurl::curl_interface::global_initialisator::~global_initialisator()': server.cpp:(.text._ZN4curl14curl_interfaceI8CURLcodeE20global_initialisatorD2Ev[_ZN4curl14curl_interfaceI8CURLcodeE20global_initialisatorD5Ev]+0x1): undefined reference to curl_global_cleanup' CMakeFiles/server.dir/source_code/server.cpp.o: In functioncurl::curl_easy_exception::~curl_easy_exception()': server.cpp:(.text._ZN4curl19curl_easy_exceptionD2Ev[_ZN4curl19curl_easy_exceptionD5Ev]+0xb): undefined reference to curl::curl_exception::~curl_exception()' CMakeFiles/server.dir/source_code/server.cpp.o: In functioncurl::curl_easy_exception::~curl_easy_exception()': server.cpp:(.text._ZN4curl19curl_easy_exceptionD0Ev[_ZN4curl19curl_easy_exceptionD5Ev]+0xf): undefined reference to curl::curl_exception::~curl_exception()' CMakeFiles/server.dir/source_code/server.cpp.o: In functioncurl::curl_easy_exception::curl_easy_exception(CURLcode const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)': server.cpp:(.text._ZN4curl19curl_easy_exceptionC2ERK8CURLcodeRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN4curl19curl_easy_exceptionC5ERK8CURLcodeRKNSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x29): undefined reference to curl_easy_strerror' server.cpp:(.text._ZN4curl19curl_easy_exceptionC2ERK8CURLcodeRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN4curl19curl_easy_exceptionC5ERK8CURLcodeRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x42): undefined reference tocurl::curl_exception::curl_exception(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' CMakeFiles/server.dir/source_code/server.cpp.o: In function std::thread::thread<void (&)(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::map<int, 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::less<int>, std::allocator<std::pair<int 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> > > > > > >*), 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::map<int, 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::less<int>, std::allocator<std::pair<int 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> > > > > > >*&>(void (&)(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::map<int, 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::less<int>, std::allocator<std::pair<int 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> > > > > > >*), 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::map<int, 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::less<int>, std::allocator<std::pair<int 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> > > > > > >*&)': server.cpp:(.text._ZNSt6threadC2IRFvRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EEPSt3mapIiS9_St4lessIiESaISt4pairIKiS9_EEEEJRS9_RSK_EEEOT_DpOT0_[_ZNSt6threadC5IRFvRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EEPSt3mapIiS9_St4lessIiESaISt4pairIKiS9_EEEEJRS9_RSK_EEEOT_DpOT0_]+0xaf): undefined reference topthread_create' CMakeFiles/server.dir/source_code/server.cpp.o: In function curl::curl_easy::curl_easy<std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> > >(curl::curl_ios<std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> > >&)': server.cpp:(.text._ZN4curl9curl_easyC2INSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEEERNS_8curl_iosIT_EE[_ZN4curl9curl_easyC5INSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEEERNS_8curl_iosIT_EE]+0x38): undefined reference tovtable for curl::curl_easy' server.cpp:(.text._ZN4curl9curl_easyC2INSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEEERNS_8curl_iosIT_EE[_ZN4curl9curl_easyC5INSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEEERNS_8curl_iosIT_EE]+0x40): undefined reference to `curl_easy_init' server.cpp:(.text._ZN4curl9curl_easyC2INSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEEERNS_8curl_iosIT_EE[_ZN4curl9curl_easyC5INSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEEERNS_8curl_iosIT_EE]+0x60): undefined reference to `curl_easy_setopt' server.cpp:(.text._ZN4curl9curl_easyC2INSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEEERNS_8curl_iosIT_EE[_ZN4curl9curl_easyC5INSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEEERNS_8curl_iosIT_EE]+0x80): undefined reference to curl_easy_setopt' server.cpp:(.text._ZN4curl9curl_easyC2INSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEEERNS_8curl_iosIT_EE[_ZN4curl9curl_easyC5INSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEEERNS_8curl_iosIT_EE]+0xca): undefined reference tocurl_global_init' server.cpp:(.text._ZN4curl9curl_easyC2INSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEEERNS_8curl_iosIT_EE[_ZN4curl9curl_easyC5INSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEEERNS_8curl_iosIT_EE]+0x144): undefined reference to `curl::curl_exception::curl_exception(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' CMakeFiles/server.dir/source_code/server.cpp.o: In function void curl::curl_easy::add<(CURLoption)10002>(curl::detail::option_t<(CURLoption)10002>::type)': server.cpp:(.text._ZN4curl9curl_easy3addIL10CURLoption10002EEEvNS_6detail8option_tIXT_EE4typeE[_ZN4curl9curl_easy3addIL10CURLoption10002EEEvNS_6detail8option_tIXT_EE4typeE]+0x25): undefined reference tocurl_easy_setopt' CMakeFiles/server.dir/source_code/server.cpp.o: In function void curl::curl_easy::add<(CURLoption)52>(curl::detail::option_t<(CURLoption)52>::type)': server.cpp:(.text._ZN4curl9curl_easy3addIL10CURLoption52EEEvNS_6detail8option_tIXT_EE4typeE[_ZN4curl9curl_easy3addIL10CURLoption52EEEvNS_6detail8option_tIXT_EE4typeE]+0x25): undefined reference tocurl_easy_setopt' CMakeFiles/server.dir/source_code/server.cpp.o: In function `std::cxx11::basic_stringstream<char, std::char_traits, std::allocator >* request::send_request_ss(std::cxx11::basic_string<char, std::char_traits, std::allocator >&)': server.cpp:(.text._ZN7request15send_request_ssIcEEPNSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE[_ZN7request15send_request_ssIcEEPNSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE]+0x78): undefined reference to `curl::curl_easy::perform()' server.cpp:(.text._ZN7request15send_request_ssIcEEPNSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE[_ZN7request15send_request_ssIcEEPNSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE]+0x80): undefined reference to `curl::curl_easy::~curl_easy()' server.cpp:(.text._ZN7request15send_request_ssIcEEPNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE[_ZN7request15send_request_ssIcEEPNSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE]+0xd7): undefined reference to curl::curl_exception::curl_exception(curl::curl_exception const&)' server.cpp:(.text._ZN7request15send_request_ssIcEEPNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE[_ZN7request15send_request_ssIcEEPNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE]+0xf8): undefined reference tocurl::curl_exception::tracebackLocker' server.cpp:(.text._ZN7request15send_request_ssIcEEPNSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE[_ZN7request15send_request_ssIcEEPNSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE]+0x104): undefined reference to `curl::curl_exception::traceback[abi:cxx11]' server.cpp:(.text._ZN7request15send_request_ssIcEEPNSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE[_ZN7request15send_request_ssIcEEPNSt7cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE]+0x11d): undefined reference to curl::curl_exception::tracebackLocker' server.cpp:(.text._ZN7request15send_request_ssIcEEPNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE[_ZN7request15send_request_ssIcEEPNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEERNS1_12basic_stringIT_S3_IS9_ESaIS9_EEE]+0x137): undefined reference tocurl::curl_exception::~curl_exception()' CMakeFiles/server.dir/source_code/server.cpp.o: In function search_GitHub(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::map<int, 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::less<int>, std::allocator<std::pair<int 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> > > > > > >*)': server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0x216): undefined reference tocurl::curl_header::curl_header()' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0x23d): undefined reference to `curl::curl_header::add(std::cxx11::basic_string<char, std::char_traits, std::allocator >)' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0x26d): undefined reference to curl::curl_header::add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0x29f): undefined reference tocurl_easy_setopt' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0x2d3): undefined reference to `curl::curl_easy::perform()' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0x2db): undefined reference to curl::curl_easy::~curl_easy()' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0x2e7): undefined reference tocurl::curl_header::~curl_header()' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0x9f0): undefined reference to `curl::curl_exception::curl_exception(curl::curl_exception const&)' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0xa1b): undefined reference to curl::curl_exception::tracebackLocker' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0xa2c): undefined reference tocurl::curl_exception::traceback[abi:cxx11]' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0xa42): undefined reference to `curl::curl_exception::tracebackLocker' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0xa4e): undefined reference to curl::curl_exception::tracebackLocker' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0xa5a): undefined reference tocurl::curl_exception::traceback[abi:cxx11]' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0xa75): undefined reference to `curl::curl_exception::traceback[abi:cxx11]' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0xaaa): undefined reference to curl::curl_exception::tracebackLocker' server.cpp:(.text._Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE[_Z13search_GitHubRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEPSt3mapIiS7_St4lessIiESaISt4pairIKiS7_EEE]+0xacb): undefined reference tocurl::curl_exception::~curl_exception()' CMakeFiles/server.dir/source_code/server.cpp.o:(.data.rel.ro._ZTIN4curl19curl_easy_exceptionE[_ZTIN4curl19curl_easy_exceptionE]+0x10): undefined reference to typeinfo for curl::curl_exception' collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/server.dir/build.make:95: server] Error 1 make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/server.dir/all] Error 2 make: *** [Makefile:130: all] Error 2 And here is what I include in my CMakeLists.txt :

ADD_SUBDIRECTORY(source_code/external_includes/curlcpp) INCLUDE_DIRECTORIES(${CURLCPP_SOURCE_DIR}/include)

I have no problem compiling normally from the command line , it's just my CMake that has the problem.

It's not a major issue, but I leave it here in case someone can find a solution!

Thanks in advance :)

stav121 commented 7 years ago

Closed : Found the answer, I had a bad line in my CMakeLists.txt , changed it and everything got fixed.

JosephP91 commented 7 years ago

@unix121 Good!