使用LibCURL C ++ [英] Using LibCURL C++

查看:416
本文介绍了使用LibCURL C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图在C ++中使用LibCURL几个小时,它真的让我的神经。我有一个感觉,其他人已经有一个这样的问题,但我没有找到和帖子给我一个解决方案。



这是我done:



由于)

  • 在Code :: Blocks中,右键点击您的项目并打开构建选项。

  • 转到链接器设置,然后将curldll添加到链接库 (图片

  • 转到搜索目录,在编译器下将其链接到路径您的'curl-7.24.0-devel-mingw32 \include'文件夹中。

  • 转到搜索目录下的链接器选项卡,

  • 将curl-7.24.0-devel-mingw32\bin文件夹中的所有DLL移动到项目的bin



  • 建立并享受







    1. 将所有必要的文件/ dll /库移到调试文件夹中。确保您包含'curl'文件夹。

    2. 转到您的.pro文件,并添加libcurldll.a文件的位置。例如(我的):



      LIBS + = C:\libcurl\7.24.0\lib\libcurldll.a


    3. 享受。


    感谢 R。 Martinho Fernandes


    I've been trying to use LibCURL in C++ for a couple hours now, and it is really getting on my nerves. I have a feeling someone else has had a problem like this before, but I haven't found and posts that have given me a solution.

    This is what I've done:

    Since the libCurl download page is so confusing, I am posting exactly what I've done. First, I downloaded the file at the top (curl-7.23.1.zip), and then opened it in winRAR. I then went into the include folder, and then extracted the 'curl' folder out of there.

    I then created a new project with Code::Blocks, and then moved the 'curl' folder into the same folder as my project.

    I then add '#include "curl/curl.h"' to the top of my file, and then try and initialize a simple CURL var... I then get an error, saying:

    ...\main.cpp|22|undefined reference to `_imp__curl_easy_init'|
    

    Here is a picture of the actual code/error:

    Honestly, I think it is something very very stupid that I am doing, but I just don't know what to do.

    解决方案

    Finally got it to work with some of help

    Here is how I did it:

    1. Download the 'Win32 Generic' libcurl package. (7.24.0)
    2. In Code::Blocks, right click your project and open the build options.
    3. Go to 'Linker Settings' and add 'curldll' into the 'Link Libraries' listbox. (image)
    4. Go to 'Search Directories' and under 'Compiler' link it to the path of your 'curl-7.24.0-devel-mingw32\include' folder.
    5. Go to the 'Linker' tab under 'Search Directories', and add the path of your 'curl-7.24.0-devel-mingw32\lib' directory.
    6. Move all DLLs from your 'curl-7.24.0-devel-mingw32\bin' folder into your projects 'bin' folder.
    7. Build and enjoy


    To use libCurl with Qt, it is a bit easier.

    1. Move all necessary files/dlls/libraries into your debug folder. Make sure that you include the 'curl' folder.
    2. Go to your .pro file, and add the location of the 'libcurldll.a' file. For example(mine):

      LIBS += C:\libcurl\7.24.0\lib\libcurldll.a

    3. Enjoy.

    Thanks R. Martinho Fernandes!

    这篇关于使用LibCURL C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆