VS集成libcurl时遇到的问题总结

描述

libcurl作为一个优秀的网络库,经常被集成到工程中。记录一下在VS中集成libcurl出现了问题,之所以需要单独记录,是因为问题比较多,⊙﹏⊙b汗!

注:这些问题的方案大都来自其他博主,在此汇总记录。

基本问题

首先的问题是libcurl的配置,当然,这其实也不能算是个问题:工程配置中添加头文件和lib文件的引用

头文件:项目右键--》属性--》配置属性--》C/C++--》附件包含目录

lib文件路径:项目右键--》属性--》配置属性--》链接器--》附件库目录

lib文件:项目右键--》属性--》配置属性--》链接器--》输入--》附件依赖项

链接问题

1、首先出现的连接问题是:

error LNK2001: 无法解析的外部符号 __imp_curl_easy_perform
error LNK2001: 无法解析的外部符号 __imp_curl_easy_init
error LNK2001: 无法解析的外部符号 __imp_curl_slist_append
error LNK2001: 无法解析的外部符号 __imp_curl_slist_free_all
error LNK2001: 无法解析的外部符号 __imp_curl_easy_cleanup
error LNK2001: 无法解析的外部符号 __imp_curl_easy_setopt

解决方案:加入预编译选项:项目右键--》属性--》配置属性--》C/C++--》预处理器--》预处理器,把 BUILDING_LIBCURL或CURL_STATICLIB

2、接着出现的问题是:

1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_init
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_unbind_s
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_set_option
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_simple_bind_s
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_search_s
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_msgfree
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_err2string
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_first_entry
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_next_entry
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_first_attribute
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_next_attribute
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_get_values_len
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_value_free_len
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_get_dn
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_memfree
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ber_free

解决方案:给工程添加依赖的库:项目右键--》属性--》配置属性--》链接器--》输入--》附件依赖项,把 ws2_32.lib、 winmm.lib、 wldap32.lib添加进去

这两个问题的解决方案是参考博客:https://blog.csdn.net/q610098308/article/details/88569866?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-1&spm=1001.2101.3001.4242,感谢博主

3、最后出现的问题:

1>libeay32MDd.lib(e_capi.obj) : error LNK2001: 无法解析的外部符号__imp__CertGetCertificateContextProperty@16
1>libeay32MDd.lib(e_capi.obj) : error LNK2001: 无法解析的外部符号 __imp__CertOpenStore@20
1>libeay32MDd.lib(e_capi.obj) : error LNK2001: 无法解析的外部符号 __imp__CertCloseStore@8
1>libeay32MDd.lib(e_capi.obj) : error LNK2001: 无法解析的外部符号 __imp__CertEnumCertificatesInStore@8
1>libeay32MDd.lib(e_capi.obj) : error LNK2001: 无法解析的外部符号 __imp__CertFreeCertificateContext@4
1>libeay32MDd.lib(e_capi.obj) : error LNK2001: 无法解析的外部符号 __imp__CertFindCertificateInStore@24
1>libeay32MDd.lib(e_capi.obj) : error LNK2001: 无法解析的外部符号 __imp__CertDuplicateCertificateContext@4

解决方案:给工程添加依赖的库:项目右键--》属性--》配置属性--》链接器--》输入--》附件依赖项,把 Crypt32.lib添加进去

参考博客:https://blog.csdn.net/diaoxuesong/article/details/78664663

4、最后还有个问题

winsock.h和winsock2.h冲突问题:

解决方案:加入预编译选项:项目右键--》属性--》配置属性--》C/C++--》预处理器--》预处理器,把WIN32_LEAN_AND_MEAN加进去

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值