cocos2dx添加第三方库注意事项

cocos2dx添加第三方库注意事项,第1张

概述前一段时间,使用cocos2dx 2.0,在使用中文转码的时候,老是加载出问题。  Error 1 error LNK2019: unresolved external symbol _libiconv_close referenced in function "public: int __thiscall HelloWorld::GBKToUTF8(class std::basic_string 前一段时间,使用cocos2dx 2.0,在使用中文转码的时候,老是加载出问题。

Error 1 error LNK2019: unresolved external symbol _libiconv_close referenced in function "public: int __thiscall HelloWorld::GBKToUTF8(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,char const *,char const *)" (?GBKToUTF8@HelloWorld@@QAEHAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBD1@Z) F:\cocos2d\cocos2d2\HelloWorld\proj.win32\HelloWorldScene.obj HelloWorld
Error 2 error LNK2019: unresolved external symbol _libiconv referenced in function "public: int __thiscall HelloWorld::GBKToUTF8(class std::basic_string<char,char const *)" (?GBKToUTF8@HelloWorld@@QAEHAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBD1@Z) F:\cocos2d\cocos2d2\HelloWorld\proj.win32\HelloWorldScene.obj HelloWorld
Error 3 error LNK2019: unresolved external symbol _libiconv_open referenced in function "public: int __thiscall HelloWorld::GBKToUTF8(class std::basic_string<char,char const *)" (?GBKToUTF8@HelloWorld@@QAEHAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBD1@Z) F:\cocos2d\cocos2d2\HelloWorld\proj.win32\HelloWorldScene.obj HelloWorld


,原因是在引用第三方库的时候,只写了头文件,#include "platform\third_party\win32\iconv\iconv.h" 只要在头文件附近加入 #pragma comment(lib,"libiconv.lib") 即: #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "platform\third_party\win32\iconv\iconv.h" #pragma comment(lib,"libiconv.lib") #endif 可解决中文问题,下面附带函数: int HelloWorld::GBKToUTF8(std::string &gbkStr,const char* toCode,const char* formCode) { iconv_t iconvH; iconvH = iconv_open(formCode,toCode); if(iconvH == 0) { return -1; } const char* strChar = gbkStr.c_str(); const char** pin = &strChar; size_t strLength = gbkStr.length(); char* outbuf = (char*)malloc(strLength*4); char* pBuff = outbuf; memset(outbuf,strLength*4); size_t outLength = strLength*4; if(-1 == iconv(iconvH,pin,&strLength,&outbuf,&outLength)) { iconv_close(iconvH); return -1; } gbkStr = pBuff; iconv_close(iconvH); return 0; } //----------------------------------------------------- std::string Title = "啊看见电算会计快接啊但是"; #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) GBKToUTF8(Title,"gb2312","utf-8"); #endif cclabelTTF* pLabel = cclabelTTF::create(Title.c_str(),"Thonburi",24); 总结

以上是内存溢出为你收集整理的cocos2dx添加第三方库注意事项全部内容,希望文章能够帮你解决cocos2dx添加第三方库注意事项所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1007286.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存