无法编译curlpp

时间:2011-11-04 00:26:12

标签: c++ codeblocks curlpp

我现在已经在这几个小时了(而且就在今天)所以我真的可以使用一些帮助。我总是在Windows环境中编写代码,因此我尝试将curlpp添加到我的Code :: Blocks项目中。

  1. 我下载了curl-7.22.0-devel-mingw32并将所有这些库添加到Code :: Blocks项目中。
  2. 我下载了curl-7.22.0并使用vc6curl.dsw编译了它,这使得 libcurl.lib ,将其添加到Code :: Blocks项目中。
  3. 已下载 curlpp -0.7.3
  4. 将MinGW \ lib \ libwsock32.a添加到Code :: Blocks项目。
  5. 在项目中添加了以下目录: curlpp-0.7.3 \ include curl-7.22.0 \ include
  6. 但是我得到了很多“未定义的引用”错误,所以我猜这意味着curlpp也需要编译。它包含一个VC8项目,所以我下载了Visual C ++ 2005 Express并安装。

    打开项目时遇到的第一个错误是无法加载示例。我想这不是一个真正的问题。尝试立即构建项目,给出错误“无法打开包含文件:'curl / curl.h'”,因此我将cURL包含文件夹 curl-7.22.0 \ include 添加到项目中,再试一次。

    1>------ Build started: Project: curlpp, Configuration: DebugDynamic Win32 ------
    1>Compiling...
    1>cURLpp.cpp
    1>C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include\curl/curl.h(62) : fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
    1>Easy.cpp
    1>C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include\curl/curl.h(62) : fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
    1>Exception.cpp
    1>C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include\curl/curl.h(62) : fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
    1>Form.cpp
    1>C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include\curl/curl.h(62) : fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
    1>Info.cpp
    1>C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include\curl/curl.h(62) : fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
    1>Multi.cpp
    1>C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include\curl/curl.h(62) : fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
    1>OptionBase.cpp
    1>C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include\curl/curl.h(62) : fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
    1>Options.cpp
    1>C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include\curl/curl.h(62) : fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
    1>CurlHandle.cpp
    1>C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include\curl/curl.h(62) : fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
    1>OptionList.cpp
    1>C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include\curl/curl.h(62) : fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
    1>OptionSetter.cpp
    1>C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include\curl/curl.h(62) : fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
    1>SList.cpp
    1>C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include\curl/curl.h(62) : fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
    1>WIN32
    1>c1xx : fatal error C1083: Cannot open source file: 'WIN32': Permission denied
    1>Generating Code...
    1>Project : warning PRJ0018 : The following environment variables were not found:
    1>$(BOOST_PATH)
    1>$(LIBCURL_PATH)
    1>Build log was saved at "file://c:\Users\admin\Downloads\curlpp-0.7.3-2\curlpp-0.7.3\DebugDynamic\BuildLog.htm"
    1>curlpp - 13 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    

    错误时出错,这让我疯狂。 Googeling一个人也没有真正帮助。我发现一些论坛帖子说必须添加WS2_32.Lib,并且它位于 C:\ Program Files(x86)\ Microsoft SDKs \ Windows \ v7.0A \ Lib 中,但是将其添加到libraries文件夹在VS2005项目中似乎没有做任何事情。

    我只是在忘记这一切......这应该是怎么回事?我认为它会如此简单:

    1. 编译卷曲
    2. 编译curlpp
    3. 利润!
    4. 但不幸的是,这似乎并不那么容易。

      更新

      哦,是的,我忘记了,最初我也遇到了这些错误:

      c1xx : fatal error C1083: Cannot open source file: '.\src\curlpp\Infos.cpp': No such file or directory
      
      c1xx : fatal error C1083: Cannot open source file: '.\src\curlpp\Option.cpp': No such file or directory
      
      c1xx : fatal error C1083: Cannot open source file: '.\src\utilspp\singleton\LifetimeLibrary.cpp': No such file or directory
      
      c1xx : fatal error C1083: Cannot open source file: '.\src\utilspp\singleton\PrivateMembers.cpp': No such file or directory
      

      但是在 src \ curlpp 中有:

      Info.cpp
      Options.cpp
      

      所以我只是将它们复制并重命名为

      Info2.cpp
      Option.cpp
      

      src \ utilspp 中有

      LifetimeLibrary.cpp
      PrivateMembers.cpp
      

      所以我在那里创建了一个文件夹“singleton”并将文件复制到那里。

      好像curlpp被打破了?但它一定是我做的奇怪事情,因为有人会注意到它!

      UPDATE2 好的,我从头开始,发现我还必须从windows SDK添加 includes 文件夹。这照顾了无法打开包含文件:'winsock2.h'错误。但现在我收到了其他一些错误:

      1>------ Build started: Project: curlpp, Configuration: DebugDynamic Win32 ------
      1>Linking...
      1>Infos.obj : error LNK2005: "public: static void __cdecl curlpp::InfoTypeConverter<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::get(class curlpp::Easy &,enum CURLINFO,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?get@?$InfoTypeConverter@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@curlpp@@SAXAAVEasy@2@W4CURLINFO@@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in Info.obj
      1>Infos.obj : error LNK2005: "public: static void __cdecl curlpp::InfoTypeConverter<class std::list<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > >::get(class curlpp::Easy &,enum CURLINFO,class std::list<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &)" (?get@?$InfoTypeConverter@V?$list@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@curlpp@@SAXAAVEasy@2@W4CURLINFO@@AAV?$list@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@Z) already defined in Info.obj
      1>Infos.obj : error LNK2005: "public: static void __cdecl curlpp::InfoTypeConverter<long>::get(class curlpp::Easy &,enum CURLINFO,long &)" (?get@?$InfoTypeConverter@J@curlpp@@SAXAAVEasy@2@W4CURLINFO@@AAJ@Z) already defined in Info.obj
      1>Infos.obj : error LNK2005: "public: static void __cdecl curlpp::InfoTypeConverter<double>::get(class curlpp::Easy &,enum CURLINFO,double &)" (?get@?$InfoTypeConverter@N@curlpp@@SAXAAVEasy@2@W4CURLINFO@@AAN@Z) already defined in Info.obj
      1>Options.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class curlpp::OptionTrait<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,10002> const &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABV?$OptionTrait@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@$0CHBC@@curlpp@@@Z) already defined in Option.obj
      1>   Creating library DebugDynamic\curlpp.lib and object DebugDynamic\curlpp.exp
      1>cURLpp.obj : error LNK2019: unresolved external symbol __imp__curl_global_init referenced in function "void __cdecl curlpp::initialize(long)" (?initialize@curlpp@@YAXJ@Z)
      1>cURLpp.obj : error LNK2019: unresolved external symbol __imp__curl_global_cleanup referenced in function "void __cdecl curlpp::terminate(void)" (?terminate@curlpp@@YAXXZ)
      1>cURLpp.obj : error LNK2019: unresolved external symbol __imp__curl_free referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl curlpp::escape(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?escape@curlpp@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
      1>cURLpp.obj : error LNK2019: unresolved external symbol __imp__curl_escape referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl curlpp::escape(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?escape@curlpp@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
      1>cURLpp.obj : error LNK2019: unresolved external symbol __imp__curl_unescape referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl curlpp::unescape(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?unescape@curlpp@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
      1>cURLpp.obj : error LNK2019: unresolved external symbol __imp__curl_getenv referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl curlpp::getenv(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?getenv@curlpp@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
      1>cURLpp.obj : error LNK2019: unresolved external symbol __imp__curl_version referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl curlpp::libcurlVersion(void)" (?libcurlVersion@curlpp@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
      1>cURLpp.obj : error LNK2019: unresolved external symbol __imp__curl_getdate referenced in function "__int64 __cdecl curlpp::getdate(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,__int64 *)" (?getdate@curlpp@@YA_JABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PA_J@Z)
      1>Form.obj : error LNK2019: unresolved external symbol __imp__curl_formfree referenced in function "public: void __thiscall curlpp::HttpPost::clear(void)" (?clear@HttpPost@curlpp@@QAEXXZ)
      1>Form.obj : error LNK2019: unresolved external symbol __imp__curl_formadd referenced in function "private: virtual void __thiscall curlpp::FormParts::File::add(struct curl_httppost * *,struct curl_httppost * *)" (?add@File@FormParts@curlpp@@EAEXPAPAUcurl_httppost@@0@Z)
      1>Info.obj : error LNK2019: unresolved external symbol __imp__curl_easy_getinfo referenced in function "public: void __thiscall curlpp::internal::CurlHandle::getInfo<char *>(enum CURLINFO,char * &)" (??$getInfo@PAD@CurlHandle@internal@curlpp@@QAEXW4CURLINFO@@AAPAD@Z)
      1>Infos.obj : error LNK2001: unresolved external symbol __imp__curl_easy_getinfo
      1>Multi.obj : error LNK2019: unresolved external symbol __imp__curl_multi_init referenced in function "public: __thiscall curlpp::Multi::Multi(void)" (??0Multi@curlpp@@QAE@XZ)
      1>Multi.obj : error LNK2019: unresolved external symbol __imp__curl_multi_cleanup referenced in function "public: __thiscall curlpp::Multi::~Multi(void)" (??1Multi@curlpp@@QAE@XZ)
      1>Multi.obj : error LNK2019: unresolved external symbol __imp__curl_multi_remove_handle referenced in function "public: __thiscall curlpp::Multi::~Multi(void)" (??1Multi@curlpp@@QAE@XZ)
      1>Multi.obj : error LNK2019: unresolved external symbol __imp__curl_multi_strerror referenced in function "public: void __thiscall curlpp::Multi::add(class curlpp::Easy const *)" (?add@Multi@curlpp@@QAEXPBVEasy@2@@Z)
      1>Multi.obj : error LNK2019: unresolved external symbol __imp__curl_multi_add_handle referenced in function "public: void __thiscall curlpp::Multi::add(class curlpp::Easy const *)" (?add@Multi@curlpp@@QAEXPBVEasy@2@@Z)
      1>Multi.obj : error LNK2019: unresolved external symbol __imp__curl_multi_perform referenced in function "public: bool __thiscall curlpp::Multi::perform(int *)" (?perform@Multi@curlpp@@QAE_NPAH@Z)
      1>Multi.obj : error LNK2019: unresolved external symbol __imp__curl_multi_fdset referenced in function "public: void __thiscall curlpp::Multi::fdset(struct fd_set *,struct fd_set *,struct fd_set *,int *)" (?fdset@Multi@curlpp@@QAEXPAUfd_set@@00PAH@Z)
      1>Multi.obj : error LNK2019: unresolved external symbol __imp__curl_multi_info_read referenced in function "public: class std::list<struct std::pair<class curlpp::Easy const *,struct curlpp::Multi::Info>,class std::allocator<struct std::pair<class curlpp::Easy const *,struct curlpp::Multi::Info> > > __thiscall curlpp::Multi::info(void)" (?info@Multi@curlpp@@QAE?AV?$list@U?$pair@PBVEasy@curlpp@@UInfo@Multi@2@@std@@V?$allocator@U?$pair@PBVEasy@curlpp@@UInfo@Multi@2@@std@@@2@@std@@XZ)
      1>Option.obj : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function "public: void __thiscall curlpp::internal::CurlHandle::option<void *>(enum CURLoption,void *)" (??$option@PAX@CurlHandle@internal@curlpp@@QAEXW4CURLoption@@PAX@Z)
      1>Options.obj : error LNK2001: unresolved external symbol __imp__curl_easy_setopt
      1>CurlHandle.obj : error LNK2001: unresolved external symbol __imp__curl_easy_setopt
      1>OptionSetter.obj : error LNK2001: unresolved external symbol __imp__curl_easy_setopt
      1>CurlHandle.obj : error LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function "public: void __thiscall curlpp::internal::CurlHandle::perform(void)" (?perform@CurlHandle@internal@curlpp@@QAEXXZ)
      1>CurlHandle.obj : error LNK2019: unresolved external symbol __imp__curl_easy_reset referenced in function "public: void __thiscall curlpp::internal::CurlHandle::reset(void)" (?reset@CurlHandle@internal@curlpp@@QAEXXZ)
      1>CurlHandle.obj : error LNK2019: unresolved external symbol __imp__curl_easy_init referenced in function "public: __thiscall curlpp::internal::CurlHandle::CurlHandle(void)" (??0CurlHandle@internal@curlpp@@QAE@XZ)
      1>CurlHandle.obj : error LNK2019: unresolved external symbol __imp__curl_easy_duphandle referenced in function "public: class std::auto_ptr<class curlpp::internal::CurlHandle> __thiscall curlpp::internal::CurlHandle::clone(void)const " (?clone@CurlHandle@internal@curlpp@@QBE?AV?$auto_ptr@VCurlHandle@internal@curlpp@@@std@@XZ)
      1>CurlHandle.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function "public: virtual __thiscall curlpp::internal::CurlHandle::~CurlHandle(void)" (??1CurlHandle@internal@curlpp@@UAE@XZ)
      1>SList.obj : error LNK2019: unresolved external symbol __imp__curl_slist_free_all referenced in function "private: void __thiscall curlpp::internal::SList::clear(void)" (?clear@SList@internal@curlpp@@AAEXXZ)
      1>SList.obj : error LNK2019: unresolved external symbol __imp__curl_slist_append referenced in function "private: void __thiscall curlpp::internal::SList::update(void)" (?update@SList@internal@curlpp@@AAEXXZ)
      1>DebugDynamic\curlpp.dll : fatal error LNK1120: 27 unresolved externals
      1>Project : warning PRJ0018 : The following environment variables were not found:
      1>$(BOOST_PATH)
      1>Build log was saved at "file://c:\Users\admin\Downloads\curlpp-0.7.3\curlpp-0.7.3\DebugDynamic\BuildLog.htm"
      1>curlpp - 37 error(s), 0 warning(s)
      ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
      

      这会永远结束吗?

      其他库现在看起来像这样:

      "C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\lib\Debug";
      "C:\Program Files (x86)\CodeBlocks\MinGW\lib";
      "C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\lib";
      "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib";
      "C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib"
      

      包括:

      "C:\Program Files\Microsoft SDKs\Windows\v7.1\Include";
      "C:\Users\admin\Downloads\curl-7.22.0\curl-7.22.0\include";
      .\;
      include\curlpp;
      include;
      "$(BOOST_PATH)"
      

      什么是BOOST PATH?

      而且,为了摆脱“libcurl.lib not found”错误,我打开了我在curl-7.22.0中找到并编译它的项目,但这意味着libcurl.lib位于“lib \ Debug”中正如你在上面看到的那样我包含的文件夹,我是否正确地做到了?

      UPDATE3:

      我注意到一个名为 create-vc-solution.bat 的文件,因此,在为Windows下载“sed”之后,我尝试为VS9创建一个vc解决方案(没有10的选项)希望会工作,但这是我打开在VS2010中创建的解决方案文件时得到的结果:

      Converting project file 'C:\Users\admin\Downloads\curlpp-0.7.3\curlpp-0.7.3\curlpp.examples.VC9.vcproj'. 
      File 'C:\Users\admin\Downloads\curlpp-0.7.3\curlpp-0.7.3\curlpp.examples.VC9.vcproj' was not found. 
      Project upgrade failed. 
      
      Converting project file 'C:\Users\admin\Downloads\curlpp-0.7.3\curlpp-0.7.3\curlpp.VC9.vcproj'. 
      File 'C:\Users\admin\Downloads\curlpp-0.7.3\curlpp-0.7.3\curlpp.VC9.vcproj' was not found. 
      Project upgrade failed. 
      
      甚至从未创建过

      curlpp.examples.VC9.vcproj curlpp.VC9.vcproj 。 curlpp有没有经过测试?任何人?我开始认为这不再是我的错了。

1 个答案:

答案 0 :(得分:0)

我看到你正在将curlpp编译成动态库。那是你想要的吗?您应该将 libcurl.lib 添加到链接器输入。