【问题标题】:Problems compiling code with libcurl in Netbeans in Windows/Cygwin在 Windows/Cygwin 的 Netbeans 中使用 libcurl 编译代码时出现问题
【发布时间】:2014-08-11 15:31:48
【问题描述】:

我刚开始使用 C++,但在使用 libcurl 的 Windows/Cygwin 中编译代码时遇到问题。我相信我正确安装了库,但是当我尝试编译这段代码时:

#include <stdio.h>
#include <curl/curl.h>

int main(void)
{
CURL *curl;
CURLcode res;

curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* example.com is redirected, so we tell libcurl to follow redirection */ 
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

/* Perform the request, res will get the return code */ 
res = curl_easy_perform(curl);
/* Check for errors */ 
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));

/* always cleanup */ 
curl_easy_cleanup(curl);
}
return 0;
}

我收到以下错误:

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/c/Users/Eric/Documents/NetBeansProjects/Welcome_1'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-    Windows/welcome_1.exe
make[2]: Entering directory     '/cygdrive/c/Users/Eric/Documents/NetBeansProjects/Welcome_1'
mkdir -p dist/Debug/Cygwin_4.x-Windows
g++     -o dist/Debug/Cygwin_4.x-Windows/welcome_1 build/Debug/Cygwin_4.x-    Windows/welcome.o -lcygcurl-4
/usr/bin/ld: cannot find -lcygcurl-4
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/Cygwin_4.x-    Windows/welcome_1.exe' failed
make[2]: *** [dist/Debug/Cygwin_4.x-Windows/welcome_1.exe] Error 1
make[2]: Leaving directory     '/cygdrive/c/Users/Eric/Documents/NetBeansProjects/Welcome_1'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory     '/cygdrive/c/Users/Eric/Documents/NetBeansProjects/Welcome_1'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 667ms)

【问题讨论】:

  • libcygcurl-4.so 真的存在吗?如果是这样,请尝试使用链接器的选项 -L 添加库路径。
  • 谢谢,我通过在项目的“属性”选项卡上手动包含库解决了这个问题

标签: c++ windows curl netbeans cygwin


【解决方案1】:

回答只是为了结束这个问题。

对于恢复:通过在 «Properties» 选项卡中包含 Curl 库,您成功避免了错误。

【讨论】:

    猜你喜欢
    • 2014-08-13
    • 2013-09-22
    • 1970-01-01
    • 2013-08-13
    • 1970-01-01
    • 2014-10-24
    • 2020-07-17
    • 1970-01-01
    • 2020-02-09
    相关资源
    最近更新 更多