libcurl c ++ curl_easy_init无效

时间:2013-02-21 14:56:53

标签: c++ curl mingw libcurl

我刚尝试使用windows + mingw + eclipse juno + curl 7.29首次设置curl。我设法让它编译和构建良好。我为lcurl和lcurldll添加了两个标志。 出于某种原因,虽然以下方法不起作用:

#include <iostream>
#include <curl.h>
using namespace std;

int main(int argc,char *argv[]) {
 cout << "L1" << endl;
 CURL *curl;
 curl = curl_easy_init();
 cout << "L2" << endl;
}

L1和L2都不打印。如果我注释掉easy_init行,虽然运行正常。 我似乎无法找到任何类似的帖子,对不起,如果这是一个骗局。此外,我不能介入任何东西,因为它一旦我跑了就死了。我确定它显而易见。

提前致谢。

用于C / C ++开发人员的Eclipse IDE版本:Juno Service Release 1 构建ID:20120920-0800

curl版本:7.29.0 - 启用SSL 网址:http://curl.haxx.se/gknw.net/7.29.0/dist-w32/curl-7.29.0-devel-mingw32.zip

至于mingw不确定我有哪个版本,我只是去了http://sourceforge.net/projects/mingw/files/并下载/安装了最新的版本。

在eclipse中,在MinGW C ++链接器下,我对库进行了curl和curldll。在misc中我有静态标志 - 这是我改变的唯一编译器设置。

1 个答案:

答案 0 :(得分:0)

它对我有用,但我必须在控制台关闭之后在最后添加system("PAUSE")才能看到任何内容。

这是我的代码:

#include <curl.h>
#include <iostream>

using namespace std;

int main(void)
{
    cout << "L1" << endl;

    CURL *curl;
    curl = curl_easy_init();

    cout << "L2" << endl;

    system("PAUSE");

    return 0;
}

如果你收到消息“无法打开包含文件:'curl.h':没有这样的文件或目录”或类似的东西,这是因为你在curl的安装中遗漏了一些东西。 我花了很长时间才安装它。