我正在使用libcurl,并且在VC++ 10中得到了以下类型的链接器错误。
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_strerror referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl curl_httpget(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?curl_httpget@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV12@@Z)
怎样才能去掉函数名前面imp前缀?我正在链接到正确的库,正确的路径等。
发布于 2011-03-02 03:34:28
只要链接到__imp__
,就会出现DLL前缀。当链接到静态链接库时,它不会出现。生成的代码最有可能是针对DLL导入库进行链接的,但您使用的是静态库进行链接。
前缀是在你用__declspec(dllimport)
标记导入的函数时添加的-确保你的导入在没有链接到DLL时没有使用这个前缀。
发布于 2012-09-24 17:07:00
您必须在MSVC的项目属性中将CURL_STATICLIB添加到预处理器定义中
发布于 2011-03-02 03:39:40
您正在使用定义函数原型的头文件,该文件的说明符的计算结果为__declspec(dllimport)
您需要重新定义计算结果为this的语句(将其设置为nothing),或者完全使用不同的头文件。
通常你会看到这样的代码:
#ifdef FOO_EXPORTS
#define DLLSPEC __declspec(dllexport)
#else
#define DLLSPEC __declspec(dllimport)
#endif
...
DLLSPEC bool foo(int bar);
使用定义的FOO_EXPORTS编译项目将使用一种模式,而不定义它将使用另一种模式。
https://stackoverflow.com/questions/5159353
复制相似问题