错误LNK2019:未解析的外部符号libcurl Visual studio [英] error LNK2019: unresolved external symbol libcurl Visual studio
问题描述
我要打扫我的大脑,因为我一直试图解决这一整天。
是的,我知道这是一个链接器错误libcurl.lib我假设?
我尝试从不同的源下载libcurl并将其放在不同的地方。
这些是错误:
LibFuckingCurl.obj:error LNK2019:未解析的外部符号__imp__curl_easy_strerror在函数_main中引用
和另外4个相同类型。
这是示例代码
#include< stdio.h>
#include< 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被重定向,所以我们告诉libcurl跟随重定向* /
curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1L);
/ *执行请求,res将获得返回码* /
res = curl_easy_perform(curl);
/ *检查错误* /
if(res!= CURLE_OK)
fprintf(stderr,curl_easy_perform()failed:%s\\\
,
curl_easy_strerror ));
/ * always cleanup * /
curl_easy_cleanup(curl);
}
return 0;
}
项目的属性
C / C ++
一般 - >其他包括目录 - > C:/ Project / libcurl / include
链接器
通用 - >附加库目录 - > C:/ Project / libcurl / lib
输入 - >附加依赖关系 - > libcurl.lib
命令行:这里我可以读libcurl.lib
假设这个结构:
Project
lib
libcurl.dll
libcurl.lib
... dll的
包括
curl.h
curlbuild.h
...所有头文件
VisualStudio(其中VS放置项目)
我也试过将include包括在目录和库路径的VC ++选项中。我已经阅读了许多指南,帖子,有相同问题,忘记包含libcurl.lib
我已下载的libcurl的预建版本之一,因为CMake几乎
任何帮助解决这个问题,我会奖励你命名我的第一个孩子后你。
使用静态库在Visual Studio 2013上工作
我得到它的工作,由于一些天使。
找到这个git仓库: https://github.com/blackrosezy/build-libcurl-
如何:
运行包含在存储库中的.bat。
libcurl将在包含文件夹include和lib的第三方子文件夹中找到。
创建新的Visual Studio项目
属性 - > VC ++ - >添加目录thirdparty / include(路径)
属性 - > VC ++ - >添加库thirdparty / p>
属性 - > C ++ - >预处理器 - >添加CURL_STATICLIB
链接器 - >常规 - >附加库目录库 - > thirdparty / lib / static-debug(路径)
链接器 - >输入add:C:\xxx\xxx\xxx\build-libcurl-windows \ third-party\libcurl\ lib \static-debug\libcurl_a_debug.lib(lib文件的完整路径)
I'm about to blow my brains out since I've been trying to fix this all day. Yes, I am aware that this is a linker error to the libcurl.lib I assume? I've tried downloading libcurl from a different source and put it in different places.
These are the errors:
LibFuckingCurl.obj : error LNK2019: unresolved external symbol __imp__curl_easy_strerror referenced in function _main
and 4 more of the same kind.
This is the sample code
#include <stdio.h>
#include <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;
}
Properties for project C/C++ General -> Additional Include Directories -> C:/Project/libcurl/include
Linker General ->Additional Library Directories -> C:/Project/libcurl/lib
Input -> Additional Dependencies -> libcurl.lib
Commandline: Here I can read that libcurl.lib is stated
Assuming this structure:
Project
lib
libcurl.dll
libcurl.lib
... dll's
include
curl.h
curlbuild.h
... all the header files
VisualStudio (where VS puts the project)
I also tried putting the includes in the VC++ option for directory and library path. I've read numerous guides, posts, people who had the same problem and forgot to include the libcurl.lib
I downloaded one of the prebuilt versions of libcurl because CMake almost killed me yesterday.
Any help to solve this and I will reward you with naming my firstborn child after you. Best regards
Working on Visual Studio 2013 using Static Library
I got it to work now, thanks to some angel. Found this git repo: https://github.com/blackrosezy/build-libcurl-windows
Ran the .bat which also generated static libraries like the downloads before didnt.
How to:
Run the .bat included in the repository.
libcurl will be found in the thirdparty subfolder containing folders include and lib.
Create a new Visual Studio Project
Properties -> VC++ -> Add Directory thirdparty/include (the path)
Properties -> VC++ -> Add Library thirdparty/lib/static-debug (the path)
Properties -> C++ -> Preprocessor -> Add CURL_STATICLIB
Linker -> General -> Additional Library Directories Library -> thirdparty/lib/static-debug (the path) Linker -> Input add: C:\xxx\xxx\xxx\build-libcurl-windows\third-party\libcurl\lib\static-debug\libcurl_a_debug.lib (the full path of the lib file)
这篇关于错误LNK2019:未解析的外部符号libcurl Visual studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!