簡體   English   中英

在Windows / Cygwin中的Netbeans中使用libcurl編譯代碼時出現問題

[英]Problems compiling code with libcurl in Netbeans in Windows/Cygwin

我剛開始使用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)

回答只是為了結束這個問題。

對於恢復:通過在“屬性”選項卡中包含Curl庫,您成功避免了錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM