我正在使用Qtcreator
当我尝试编译我的解决方案时,我不断收到此错误(这是来自我的Qtcreator):
main.obj:-1: error: LNK2019: unresolved external symbol __imp__curl_easy_strerror referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol __imp__curl_easy_strerror referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function _main
debug\test.exe:-1: error: LNK1120: 5 unresolved externals
来源(这是来自其网页curl http://curl.haxx.se/libcurl/c/example.html的sample.c):
#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;
}
我将此添加到我的.pro文件
INCLUDEPATH = C:\Users\Uporabnik\Desktop\curl-7.38.0\curl-7.38.0\include
答案 0 :(得分:0)
你的.pro文件需要这样的东西:
LIBS += -lcurl -LC:/Users/Uporabnik/Desktop/curl-7.38.0/curl-7.38.0
-l
告诉我应该使用具有此名称的库,-L
告诉我们在搜索lib时应该使用这个目录(除了已经搜索过的其他目录)。在 qmake 中,即使使用MSVC工具链,这也会做正确的事情,我相信,而且不仅仅是Mingw gcc 。
注意,确切的路径和lib名称在我看来有点猜测,你可能需要调整它们。