描述
libcurl作为一个优秀的网络库,经常被集成到工程中。记录一下在VS中集成libcurl出现了问题。
注:这些问题的方案大都来自其他博主,在此汇总记录。
基本问题
首先的问题是libcurl的配置,当然,这其实也不能算是个问题:工程配置中添加头文件和lib文件的引用
头文件:项目右键–》属性–》配置属性–》C/C+±-》附件包含目录
lib文件路径:项目右键–》属性–》配置属性–》链接器–》附件库目录
lib文件:项目右键–》属性–》配置属性–》链接器–》输入–》附件依赖项
源码下载地址:https://curl.se/download/
链接问题
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加进去
5、注意库的运行模式

因为我的工程师/MT,所以编译libcurl时也要设置为 多线程(/MT)
631

被折叠的 条评论
为什么被折叠?



