libcurl链接库未导出符号的错误

libcurl链接库未导出符号的错误 

2010-04-03 13:25:56|  分类: 编程入门 |字号 订阅

在使用libcurl的时候出现一个很普遍unresolved external symbol

error LNK2001: unresolved external symbol __imp__curl_easy_perform 

error LNK2001: unresolved external symbol __imp__curl_easy_setopt 

error LNK2001: unresolved external symbol __imp__curl_easy_init 

error LNK2001: unresolved external symbol __imp__curl_easy_cleanup 

===================================================================

google了一下,发现有不少人都是出现这个问题:

When building an application that uses the static libcurl library, you must add -DCURL_STATICLIB to your CFLAGS. Otherwise the linker will look for dynamic import symbols. If you get linker error like "unknown symbol __imp__curl_easy_init ..." you have linked against the wrong (static) 

library. If you want to use the libcurl.dll and import lib, you don't need any extra CFLAGS, but use one of the import libraries below

在这里:http://curl.haxx.se/docs/faq.html#Link_errors_when_building_libcurl

所以我们这样来改

菜单-->project -->settings-->C++选项卡的General里面的Project Option里面加上-D CURL_STATICLIB (其实就相当于在Preprocessor definitions里面加上CURL_STATICLIB一样)

然后、、、

error LNK2001: unresolved external symbol __imp__WSACleanup@0

error LNK2001: unresolved external symbol __imp__WSACleanup@0

error LNK2001: unresolved external symbol __imp__timeGetTime@0

.....

再加上:

#pragma comment ( lib, "ws2_32.lib" )

#pragma comment ( lib, "winmm.lib" )

编译成功


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值