今天在使用libcurl的时候出现一个很普遍,但是叫我怎么也费了半天劲的错误 unresolved external symbol 我也得代码很简单: #include <stdio.h> curl_easy_cleanup( curl ); 但是这个错误一直烦着我,怎么弄也不行,换了好几种方法使用静态链接库,都不行. google了半个小时,发现有不少人都是出现这个问题 见:http://forums.devshed.com/c-programming-42/c-linking-problem-567669.html 这两个哥们还真是有想象力,唉不过他们想到的我也已经试过了,晕.. 最后还是再他老家,找到了答案: When building an application that uses the static libcurl library, you must 在这里:http://curl.haxx.se/docs/faq.html#Link_errors_when_building_libcur 所以我们这样来改 菜单-->project -->settings-->C++选项卡的General里面的Project Option里面加上-DCURL_STATICLIB (其实就相当于在Preprocessor definitions里面加上CURL_STATICLIB一样) 确定-->rebuild all 又出错了: libcurl.lib(easy.obj) : error LNK2001: unresolved external symbol __imp__WSACleanup@0 ..... 这个一看就明白了马上加上: #pragma comment ( lib, "ws2_32.lib" ) 编译-->叮的一个美妙的声音想起了,哈哈,编译成功 |
在程序中使用libcurl的的静态链接库产生的未导出符号的错误(zt)
最新推荐文章于 2021-07-04 02:14:01 发布