我目前在 Windows 7 x64 上编译 C++ 程序时遇到问题。
它无法以我尝试的所有方式编译:
undefined reference to `curl_easy_init'
undefined reference to `curl_easy_setopt'
undefined reference to `curl_easy_setopt'
undefined reference to `curl_easy_perform'
undefined reference to `curl_easy_strerror'
undefined reference to `curl_easy_cleanup'
守则本身:
#include <curl/curl.h>
int main(int argc, char** argv)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl, CURLOPT_URL, "http://steamcommunity.com");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl);
if(res != CURLE_OK)
{
fprintf(stderr, "curl_easy_perform() failed %s\n", curl_easy_strerror(res));
}
curl_easy_cleanup(curl);
}
else
{
}
return 0;
}
我正在编译:
g++ -DCURL_STATICLIB -g -o curlprogram curlprogram.cpp -LJ:\Projektpath -lcurl
我在 -L 指定的路径中添加了 libcurl.a,并将 libcurl.dll 放入 C:\Windows\System32。