我在将twitter API twitcurl与我的OpenFrameworks解决方案集成时遇到了麻烦。 Wiki指示声明将构建的库静态链接到我的解决方案。这是我所做的。
我遵循的步骤:
1)下载twitcurl库并在VS2012上构建它。该解决方案文件基于VS2010,因此我不得不在2012年内对其进行更新。该版本是发行版本。
2)将twitcurl.lib从其发布文件夹静态链接到我的OpenFrameworks解决方案。
这是尝试构建它后出现的错误:
1>twitcurl.lib(oauthlib.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>twitcurl.lib(oauthlib.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
1>twitcurl.lib(twitcurl.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>twitcurl.lib(twitcurl.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
1>twitcurl.lib(HMAC_SHA1.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>twitcurl.lib(HMAC_SHA1.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
1>twitcurl.lib(base64.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>twitcurl.lib(base64.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
1>twitcurl.lib(urlencode.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>twitcurl.lib(urlencode.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
通过阅读这些错误后,我了解到,在尝试将发行版静态链接到调试版本时,通常会发现这些错误。随后,我尝试了所有其他组合,尝试在调试模式下构建twitcurl,反之亦然。静态链接库的调试版本会给我带来更多错误,例如:
1>twitcurl.lib(twitcurl.obj) : error LNK2019: unresolved external symbol __imp__curl_slist_free_all referenced in function "public: bool __thiscall twitCurl::oAuthHandlePIN(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?oAuthHandlePIN@twitCurl@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>twitcurl.lib(twitcurl.obj) : error LNK2019: unresolved external symbol __imp__curl_easy_init referenced in function "public: __thiscall twitCurl::twitCurl(void)" (??0twitCurl@@QAE@XZ)
1>twitcurl.lib(twitcurl.obj) : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function "public: __thiscall twitCurl::twitCurl(void)" (??0twitCurl@@QAE@XZ)
1>twitcurl.lib(twitcurl.obj) : error LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function "public: bool __thiscall twitCurl::oAuthHandlePIN(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?oAuthHandlePIN@twitCurl@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>twitcurl.lib(twitcurl.obj) : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function "public: __thiscall twitCurl::~twitCurl(void)" (??1twitCurl@@QAE@XZ)
1>twitcurl.lib(twitcurl.obj) : error LNK2019: unresolved external symbol __imp__curl_easy_getinfo referenced in function "public: bool __thiscall twitCurl::oAuthHandlePIN(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?oAuthHandlePIN@twitCurl@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>bin\SocialBuildings_debug.exe : fatal error LNK1120: 7 unresolved externals
这是什么原因呢?以及如何找到解决方法?
非常感谢你的帮助
最佳答案
因此,通过一些更改解决了我的问题:
1)在:解决方案属性> C / C ++>预处理器>预处理器定义中
组:
_ITERATOR_DEBUG_LEVEL = 2
(试图先修改实际的dll,但失败了,损坏的dll)
2)在:解决方案属性> C / C ++>代码生成>运行时库
改成:
多线程DLL
我基本上确保这两个版本的两个字段都相同(这就是导致问题的原因)