curlpp

How do you compile example00 from the cURLpp github repo?


I installed cURLpp, and I am trying to compile example00.cpp from their GitHub repo. But, when I run g++ example00.cpp -o example00 I get this output:

/tmp/cc619KAL.o: In function main': example00.cpp:(.text+0x26): undefined reference tocurlpp::Cleanup::Cleanup()' example00.cpp:(.text+0x32): undefined reference to curlpp::Easy::Easy()' example00.cpp:(.text+0x93): undefined reference tocurlpp::Easy::perform()' example00.cpp:(.text+0x9f): undefined reference to curlpp::Easy::~Easy()' example00.cpp:(.text+0xae): undefined reference tocurlpp::Cleanup::~Cleanup()' example00.cpp:(.text+0xf5): undefined reference to curlpp::Easy::~Easy()' example00.cpp:(.text+0x10c): undefined reference tocurlpp::Cleanup::~Cleanup()' /tmp/cc619KAL.o:(.gcc_except_table+0x48): undefined reference to typeinfo for curlpp::LogicError' /tmp/cc619KAL.o:(.gcc_except_table+0x4c): undefined reference totypeinfo for curlpp::RuntimeError' /tmp/cc619KAL.o: In function curlpp::Option<std::string>::~Option()': example00.cpp:(.text._ZN6curlpp6OptionISsED2Ev[_ZN6curlpp6OptionISsED5Ev]+0x49): undefined reference tocurlpp::OptionBase::~OptionBase()' example00.cpp:(.text._ZN6curlpp6OptionISsED2Ev[_ZN6curlpp6OptionISsED5Ev]+0x6f): undefined reference to curlpp::OptionBase::~OptionBase()' /tmp/cc619KAL.o: In functioncurlpp::Option::Option(CURLoption, std::string const&)': example00.cpp:(.text._ZN6curlpp6OptionISsEC2E10CURLoptionRKSs[_ZN6curlpp6OptionISsEC5E10CURLoptionRKSs]+0x21): undefined reference to curlpp::OptionBase::OptionBase(CURLoption)' example00.cpp:(.text._ZN6curlpp6OptionISsEC2E10CURLoptionRKSs[_ZN6curlpp6OptionISsEC5E10CURLoptionRKSs]+0x5c): undefined reference tocurlpp::OptionBase::~OptionBase()' /tmp/cc619KAL.o:(.rodata._ZTVN6curlpp11OptionTraitISsL10CURLoption10002EEE[_ZTVN6curlpp11OptionTraitISsL10CURLoption10002EEE]+0x20): undefined reference to curlpp::OptionBase::operator<(curlpp::OptionBase const&) const' /tmp/cc619KAL.o:(.rodata._ZTVN6curlpp6OptionISsEE[_ZTVN6curlpp6OptionISsEE]+0x20): undefined reference tocurlpp::OptionBase::operator<(curlpp::OptionBase const&) const' /tmp/cc619KAL.o:(.rodata._ZTIN6curlpp6OptionISsEE[_ZTIN6curlpp6OptionISsEE]+0x10): undefined reference to typeinfo for curlpp::OptionBase' /tmp/cc619KAL.o: In functioncurlpp::UnsetOption::~UnsetOption()': example00.cpp:(.text._ZN6curlpp11UnsetOptionD2Ev[_ZN6curlpp11UnsetOptionD5Ev]+0x1f): undefined reference to curlpp::RuntimeError::~RuntimeError()' /tmp/cc619KAL.o: In functioncurlpp::Option::updateMeToOption(curlpp::OptionBase const&)': example00.cpp:(.text._ZN6curlpp6OptionISsE16updateMeToOptionERKNS_10OptionBaseE[_ZN6curlpp6OptionISsE16updateMeToOptionERKNS_10OptionBaseE]+0x30): undefined reference to typeinfo for curlpp::OptionBase' example00.cpp:(.text._ZN6curlpp6OptionISsE16updateMeToOptionERKNS_10OptionBaseE[_ZN6curlpp6OptionISsE16updateMeToOptionERKNS_10OptionBaseE]+0x5d): undefined reference tocurlpp::UnsetOption::UnsetOption(char const*)' /tmp/cc619KAL.o: In function curlpp::OptionTrait<std::string, (CURLoption)10002>::updateHandleToMe(curlpp::internal::CurlHandle*) const': example00.cpp:(.text._ZNK6curlpp11OptionTraitISsL10CURLoption10002EE16updateHandleToMeEPNS_8internal10CurlHandleE[_ZNK6curlpp11OptionTraitISsL10CURLoption10002EE16updateHandleToMeEPNS_8internal10CurlHandleE]+0x59): undefined reference tocurlpp::UnsetOption::UnsetOption(std::string const&)' /tmp/cc619KAL.o: In function curlpp::Option<std::string>::getValue() const': example00.cpp:(.text._ZNK6curlpp6OptionISsE8getValueEv[_ZNK6curlpp6OptionISsE8getValueEv]+0x59): undefined reference tocurlpp::UnsetOption::UnsetOption(std::string const&)' /tmp/cc619KAL.o: In function void curlpp::internal::CurlHandle::option<void*>(CURLoption, void*)': example00.cpp:(.text._ZN6curlpp8internal10CurlHandle6optionIPvEEv10CURLoptionT_[_ZN6curlpp8internal10CurlHandle6optionIPvEEv10CURLoptionT_]+0x2d): undefined reference tocurl_easy_setopt' example00.cpp:(.text.ZN6curlpp8internal10CurlHandle6optionIPvEEv10CURLoptionT[ZN6curlpp8internal10CurlHandle6optionIPvEEv10CURLoptionT]+0x45): undefined reference to curlpp::libcurlRuntimeAssert(char const*, CURLcode)' /tmp/cc619KAL.o:(.rodata._ZTIN6curlpp11UnsetOptionE[_ZTIN6curlpp11UnsetOptionE]+0x10): undefined reference totypeinfo for curlpp::RuntimeError' collect2: error: ld returned 1 exit status


Solution

  • TheWatcher_, you need to link in both curlpp and curl (adding in -lcurlpp and -lcurl to your linker line). For a more complete step-by-step, here is what you need to do.

    1. Clone the latest curlpp from github.

      git clone https://github.com/jpbarrette/curlpp.git
      
    2. Go into the git directory and prepare it for compilation

      cd curlpp
      ./autogen.sh
      ./configure
      
    3. Now, lets compile the library as well as all of the examples

      make
      

    In Summary: Once the library has been built, cd into the examples directory and run the following (pulled from make) for any of the examples (replacing the 00 with the example number required):

    cd examples
    g++ -DHAVE_CONFIG_H -I. -I../include/curlpp  -I../include   -g  -W -Wall -Werror    -I/usr/local/include -MT example00.o -MD -MP -MF .deps/example00.Tpo -c -o example00.o example00.cpp
    mv -f .deps/example00.Tpo .deps/example00.Po
    /bin/sh ../libtool --silent  --tag=CXX   --mode=link g++  -g  -W -Wall -Werror -I/usr/local/include -L../src/curlpp/ -lcurlpp -static -o example00 example00.o -lstdc++ -lcurl