我安装了cURLpp,我正在尝试从他们的GitHub仓库编译example00.cpp。但是,当我运行g++ example00.cpp -o example00
时,我得到了这个输出:
/tmp/cc619KAL.o:在函数
main': example00.cpp:(.text+0x26): undefined reference to
中curlpp :: Cleanup :: Cleanup()' example00.cpp :(。text + 0x32):未定义引用curlpp::Easy::Easy()' example00.cpp:(.text+0x93): undefined reference to
curlpp :: Easy :: perform()' example00.cpp :(。text + 0x9f):未定义引用curlpp::Easy::~Easy()' example00.cpp:(.text+0xae): undefined reference to
curlpp :: Cleanup :: ~Miniup()' example00.cpp :(。text + 0xf5):未定义引用curlpp::Easy::~Easy()' example00.cpp:(.text+0x10c): undefined reference to
curlpp :: Cleanup :: ~Miniup()' /tmp/cc619KAL.o:(.gcc_except_table+0x48):对curlpp :: RuntimeError'的typeinfo for curlpp::LogicError' /tmp/cc619KAL.o:(.gcc_except_table+0x4c): undefined reference to
typeinfo的未定义引用 /tmp/cc619KAL.o:在函数curlpp::Option<std::string>::~Option()': example00.cpp:(.text._ZN6curlpp6OptionISsED2Ev[_ZN6curlpp6OptionISsED5Ev]+0x49): undefined reference to
curlpp :: OptionBase :: ~BaseBase()' example00.cpp :(。text._ZN6curlpp6OptionISsED2Ev [_ZN6curlpp6OptionISsED5Ev] + 0x6f):未定义引用curlpp::OptionBase::~OptionBase()' /tmp/cc619KAL.o: In function
curlpp :: Option :: Option(CURLoption,std :: string const&amp;)': example00.cpp :(。text._ZN6curlpp6OptionISsEC2E10CURLoptionRKSs [_ZN6curlpp6OptionISsEC5E10CURLoptionRKSs] + 0x21):对curlpp::OptionBase::OptionBase(CURLoption)' example00.cpp:(.text._ZN6curlpp6OptionISsEC2E10CURLoptionRKSs[_ZN6curlpp6OptionISsEC5E10CURLoptionRKSs]+0x5c): undefined reference to
curlpp :: OptionBase :: ~BaseBase()'的未定义引用 /tmp/cc619KAL.o:(.rodata._ZTVN6curlpp11OptionTraitISsL10CURLoption10002EEE[_ZTVN6curlpp11OptionTraitISsL10CURLoption10002EEE]+x2020):未定义引用curlpp::OptionBase::operator<(curlpp::OptionBase const&) const' /tmp/cc619KAL.o:(.rodata._ZTVN6curlpp6OptionISsEE[_ZTVN6curlpp6OptionISsEE]+0x20): undefined reference to
curlpp :: OptionBase :: operator&lt;(curlpp :: OptionBase const&amp;)const' /tmp/cc619KAL.o:(.rodata._ZTIN6curlpp6OptionISsEE[_ZTIN6curlpp6OptionISsEE]+x10):对typeinfo for curlpp::OptionBase' /tmp/cc619KAL.o: In function
curlpp :: UnsetOption :: ~UnsetOption()'的未定义引用: example00.cpp :(。text._ZN6curlpp11UnsetOptionD2Ev [_ZN6curlpp11UnsetOptionD5Ev] + 0x1f):对curlpp::RuntimeError::~RuntimeError()' /tmp/cc619KAL.o: In function
curlpp :: Option :: updateMeToOption(curlpp :: OptionBase const&amp;)'的未定义引用: example00.cpp :(。text._ZN6curlpp6OptionISsE16updateMeToOptionERKNS_10OptionBaseE [_ZN6curlpp6OptionISsE16updateMeToOptionERKNS_10OptionBaseE] + 0x30):未定义引用typeinfo for curlpp::OptionBase' example00.cpp:(.text._ZN6curlpp6OptionISsE16updateMeToOptionERKNS_10OptionBaseE[_ZN6curlpp6OptionISsE16updateMeToOptionERKNS_10OptionBaseE]+0x5d): undefined reference to
curlpp :: UnsetOption :: UnsetOption(char const *)' /tmp/cc619KAL.o:在函数curlpp::OptionTrait<std::string, (CURLoption)10002>::updateHandleToMe(curlpp::internal::CurlHandle*) const': example00.cpp:(.text._ZNK6curlpp11OptionTraitISsL10CURLoption10002EE16updateHandleToMeEPNS_8internal10CurlHandleE[_ZNK6curlpp11OptionTraitISsL10CURLoption10002EE16updateHandleToMeEPNS_8internal10CurlHandleE]+0x59): undefined reference to
curlpp :: UnsetOption :: UnsetOption(std :: string const&amp;)'中 /tmp/cc619KAL.o:在函数curlpp::Option<std::string>::getValue() const': example00.cpp:(.text._ZNK6curlpp6OptionISsE8getValueEv[_ZNK6curlpp6OptionISsE8getValueEv]+0x59): undefined reference to
curlpp :: UnsetOption :: UnsetOption(std :: string const&amp;)'中 /tmp/cc619KAL.o:在函数void curlpp::internal::CurlHandle::option<void*>(CURLoption, void*)': example00.cpp:(.text._ZN6curlpp8internal10CurlHandle6optionIPvEEv10CURLoptionT_[_ZN6curlpp8internal10CurlHandle6optionIPvEEv10CURLoptionT_]+0x2d): undefined reference to
curl_easy_setopt'中 example00.cpp :(。text。 ZN6curlpp8internal10CurlHandle6optionIPvEEv10CURLoptionT [ ZN6curlpp8internal10CurlHandle6optionIPvEEv10CURLoptionT ] + 0x45):对curlpp :: RuntimeError'的curlpp::libcurlRuntimeAssert(char const*, CURLcode)' /tmp/cc619KAL.o:(.rodata._ZTIN6curlpp11UnsetOptionE[_ZTIN6curlpp11UnsetOptionE]+0x10): undefined reference to
typeinfo的未定义引用 collect2:错误:ld返回1退出状态
答案 0 :(得分:2)
TheWatcher_,您需要同时链接curlpp和curl(将-lcurlpp
和-lcurl
添加到链接器行)。有关更完整的分步说明,您需要执行以下操作。
从github克隆最新的curlpp。
git clone https://github.com/jpbarrette/curlpp.git
进入git目录并准备编译
cd curlpp
./autogen.sh
./configure
现在,让我们编译库以及所有示例
make
摘要:构建库后,cd进入示例目录并运行以下任一示例(从make中取出)(将00替换为所需的示例编号):
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