vs工程编译问题记录unresolved external symbol __imp_curl_easy_init

1>------ Build started: Project: TestSample, Configuration: Release x64 ------ 1>Linking... 1>libMyHttp.lib(httpclient.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance 1> Creating library D:\my_vs_proj\TestSample.lib and object D:\my_vs_proj\TestSample.exp 1>libMyHttp.lib(httpclient.obj) : error LNK2001: unresolved external symbol __imp_curl_slist_append 1>libMyHttp.lib(httpclient.obj) : error LNK2001: unresolved external symbol __imp_curl_easy_setopt 1>libMyHttp.lib(httpclient.obj) : error LNK2001: unresolved external symbol __imp_curl_easy_perform 1>libMyHttp.lib(httpclient.obj) : error LNK2001: unresolved external symbol __imp_curl_easy_cleanup 1>libMyHttp.lib(httpclient.obj) : error LNK2001: unresolved external symbol __imp_curl_global_init 1>libMyHttp.lib(httpclient.obj) : error LNK2001: unresolved external symbol __imp_curl_global_cleanup 1>libMyHttp.lib(httpclient.obj) : error LNK2001: unresolved external symbol __imp_curl_easy_init 1>D:\my_vs_proj\TestSample.exe : fatal error LNK1120: 7 unresolved externals 1>Build log was saved at "file://D:\code\develop\windows\tmp\TestSample\BuildLog.htm" 1>TestSample - 8 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 25 up-to-date, 0 skipped ==========

尝试解决:
在TestSample工程属性设置里,链接库中增加了 -lcurl, 以及c/c++-->Preprocessor-->Preprocessor Definitions中加入BUILDING_LIBCURL宏,依然报这个错误。

最终解决方法:
libMyHttp.lib对应的工程属性设置中,Preprocessor Definitions需要加入BUILDING_LIBCURL宏。

另一种原因:
整个解决方案设置改为了Release x64,而libMyHttp.lib对应的工程还是win32。因此,在新添加一个新project后,需要注意在配置里将debug/release x64/win32都逐个设置好。

以上配置检测方法:
将libMyHttp.lib对应工程加入到TestSample工程的依赖项中。编译TestSample工程后失败后,将libMyHttp.lib工程clear.然后再编译TestSample工程,可以观察到如下的内容:
1>------ Rebuild All started: Project: libMyHttp, Configuration: Debug Win32 ------ 1>Deleting intermediate and output files for project 'libMyHttp', configuration 'Debug|Win32' 1>Compiling...

以上内容很容易看到configuration和当前的x64不符合。

另一个C1905问题
2>fatal error C1905: Front end and back end not compatible (must target same processor). 2>LINK : fatal error LNK1257: code generation failed 2>Build log was saved at "file://D:\code\develop\windows\tmp\rpcserver\BuildLog.htm"

解决过程:
网上搜索了一下,只知道是工程和被引用的lib库分别用了不同的架构配置,比如一个用了X64,一个用了WIN32。但是排查了几个相关工程的属性设置,一直没找到原因。

最终解决方法:
去工程目录中,根据最近的时间,将所有生成的.lib都清理掉了,重新编译,没有问题。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值