Cocos2dx 4.0 + Fairygui 编译时候的一些问题的解决方案

cocos2dx4.0 项目构建方式改动有点大,找不到“cocos2dx.props”和“cocos2d_headers.props”在哪里,只能手动从libfairygui.vcxproj的项目文件里删掉这两行,导入到解决方案之后再手动添加必须的包含文件目录,后面再研究更好的的方法。

静态库lib编译出来之后链接到exe时,出现下面这样的无法解析的链接错误,检查了所有lib依赖情况一样后仍然如此,最后分析代码发现是需要在libfairygui库的属性里面的C++->预处理器里加上 CC_STATIC 可以解决,原因是需要告诉编译器fairgui是用静态库的方式使用cocos2d,否则就会去找cocos2d的动态库,但是cocos2d的库又是静态方式编译的,所以报错。

2>libfairygui.lib(GObject.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall cocos2d::Node::setOnEnterCallback(class std::function const &)" (__imp_?setOnEnterCallback@Node@cocos2d@@QAEXABV?$function@$$A6AXXZ@std@@@Z),该符号在函数 "protected: bool __thiscall fairygui::GObject::init(void)" (?init@GObject@fairygui@@IAE_NXZ) 中被引用
2>libfairygui.lib(GObject.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall cocos2d::Node::setOnExitCallback(class std::function const &)" (__imp_?setOnExitCallback@Node@cocos2d@@QAEXABV?$function@$$A6AXXZ@std@@@Z),该符号在函数 "protected: bool __thiscall fairygui::GObject::init(void)" (?init@GObject@fairygui@@IAE_NXZ) 中被引用
2>libfairygui.lib(UIPackage.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall cocos2d::SpriteFrame::setOriginalSizeInPixels(class cocos2d::Size const &)" (__imp_?setOriginalSizeInPixels@SpriteFrame@cocos2d@@QAEXABVSize@2@@Z),该符号在函数 "private: void __thiscall fairygui::UIPackage::loadMovieClip(class fairygui::PackageItem *)" (?loadMovieClip@UIPackage@fairygui@@AAEXPAVPackageItem@2@@Z) 中被引用
2>libfairygui.lib(UIPackage.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall cocos2d::SpriteFrame::setOriginalSize(class cocos2d::Size const &)" (__imp_?setOriginalSize@SpriteFrame@cocos2d@@QAEXABVSize@2@@Z),该符号在函数 "private: void __thiscall fairygui::UIPackage::loadMovieClip(class fairygui::PackageItem *)" (?loadMovieClip@UIPackage@fairygui@@AAEXPAVPackageItem@2@@Z) 中被引用
2>libfairygui.lib(GRoot.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: class cocos2d::Vec2 & __thiscall cocos2d::Vec2::operator-=(class cocos2d::Vec2 const &)" (__imp_??ZVec2@cocos2d@@QAEAAV01@ABV01@@Z),该符号在函数 "public: class cocos2d::Vec2 __thiscall fairygui::GRoot::getPoupPosition(class fairygui::GObject *,class fairygui::GObject *,enum fairygui::PopupDirection)" (?getPoupPosition@GRoot@fairygui@@QAE?AVVec2@cocos2d@@PAVGObject@2@0W4PopupDirection@2@@Z) 中被引用
2>libfairygui.lib(GRoot.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: static int __cdecl cocos2d::AudioEngine::play2d(class std::basic_string,class std::allocator > const &,bool,float,class cocos2d::AudioProfile const *)" (__imp_?play2d@AudioEngine@cocos2d@@SAHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_NMPBVAudioProfile@2@@Z),该符号在函数 "public: void __thiscall fairygui::GRoot::playSound(class std::basic_string,class std::allocator > const &,float)" (?playSound@GRoot@fairygui@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@M@Z) 中被引用
2>libfairygui.lib(ScrollPane.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: class cocos2d::Vec2 __thiscall cocos2d::Vec2::lerp(class cocos2d::Vec2 const &,float)const " (__imp_?lerp@Vec2@cocos2d@@QBE?AV12@ABV12@M@Z),该符号在函数 "private: void __thiscall fairygui::ScrollPane::onTouchMove(class fairygui::EventContext *)" (?onTouchMove@ScrollPane@fairygui@@AAEXPAVEventContext@2@@Z) 中被引用
2>libfairygui.lib(FUISprite.obj) : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: class cocos2d::Vec2 __thiscall cocos2d::Vec2::lerp(class cocos2d::Vec2 const &,float)const " (__imp_?lerp@Vec2@cocos2d@@QBE?AV12@ABV12@M@Z)
2>libfairygui.lib(InputProcessor.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: unsigned int __thiscall cocos2d::Director::getTotalFrames(void)" (__imp_?getTotalFrames@Director@cocos2d@@QAEIXZ),该符号在函数 "private: void __thiscall fairygui::InputProcessor::updateRecentInput(class fairygui::TouchInfo *,class fairygui::GObject *)" (?updateRecentInput@InputProcessor@fairygui@@AAEXPAVTouchInfo@2@PAVGObject@2@@Z) 中被引用
2>libfairygui.lib(InputProcessor.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: float __thiscall cocos2d::EventMouse::getScrollX(void)const " (__imp_?getScrollX@EventMouse@cocos2d@@QBEMXZ),该符号在函数 "private: void __thiscall fairygui::InputProcessor::onMouseScroll(class cocos2d::EventMouse *)" (?onMouseScroll@InputProcessor@fairygui@@AAEXPAVEventMouse@cocos2d@@@Z) 中被引用
2>libfairygui.lib(InputProcessor.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: float __thiscall cocos2d::EventMouse::getScrollY(void)const " (__imp_?getScrollY@EventMouse@cocos2d@@QBEMXZ),该符号在函数 "private: void __thiscall fairygui::InputProcessor::onMouseScroll(class cocos2d::EventMouse *)" (?onMouseScroll@InputProcessor@fairygui@@AAEXPAVEventMouse@cocos2d@@@Z) 中被引用
2>libfairygui.lib(InputProcessor.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: enum cocos2d::EventMouse::MouseButton __thiscall cocos2d::EventMouse::getMouseButton(void)const " (__imp_?getMouseButton@EventMouse@cocos2d@@QBE?AW4MouseButton@12@XZ),该符号在函数 "private: void __thiscall fairygui::InputProcessor::onMouseDown(class cocos2d::EventMouse *)" (?onMouseDown@InputProcessor@fairygui@@AAEXPAVEventMouse@cocos2d@@@Z) 中被引用
2>libfairygui.lib(InputProcessor.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: float __thiscall cocos2d::EventMouse::getCursorX(void)const " (__imp_?getCursorX@EventMouse@cocos2d@@QBEMXZ),该符号在函数 "private: void __thiscall fairygui::InputProcessor::onMouseDown(class cocos2d::EventMouse *)" (?onMouseDown@InputProcessor@fairygui@@AAEXPAVEventMouse@cocos2d@@@Z) 中被引用
2>libfairygui.lib(InputProcessor.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: float __thiscall cocos2d::EventMouse::getCursorY(void)const " (__imp_?getCursorY@EventMouse@cocos2d@@QBEMXZ),该符号在函数 "private: void __thiscall fairygui::InputProcessor::onMouseDown(class cocos2d::EventMouse *)" (?onMouseDown@InputProcessor@fairygui@@AAEXPAVEventMouse@cocos2d@@@Z) 中被引用
2>libfairygui.lib(GPath.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: class cocos2d::Vec3 __thiscall cocos2d::Vec3::lerp(class cocos2d::Vec3 const &,float)const " (__imp_?lerp@Vec3@cocos2d@@QBE?AV12@ABV12@M@Z),该符号在函数 "public: class cocos2d::Vec3 __thiscall fairygui::GPath::getPointAt(float)" (?getPointAt@GPath@fairygui@@QAE?AVVec3@cocos2d@@M@Z) 中被引用
2>libfairygui.lib(GTextInput.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual __thiscall cocos2d::ui::EditBoxDelegate::~EditBoxDelegate(void)" (__imp_??1EditBoxDelegate@ui@cocos2d@@UAE@XZ),该符号在函数 "public: virtual __thiscall fairygui::GTextInput::~GTextInput(void)" (??1GTextInput@fairygui@@UAE@XZ) 中被引用
2>libfairygui.lib(GTextInput.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall cocos2d::ui::EditBoxDelegate::EditBoxDelegate(void)" (__imp_??0EditBoxDelegate@ui@cocos2d@@QAE@XZ),该符号在函数 "public: __thiscall fairygui::GTextInput::GTextInput(void)" (??0GTextInput@fairygui@@QAE@XZ) 中被引用
2>libfairygui.lib(GTextInput.obj) : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall cocos2d::ui::EditBoxDelegate::editBoxEditingDidBegin(class cocos2d::ui::EditBox *)" (?editBoxEditingDidBegin@EditBoxDelegate@ui@cocos2d@@UAEXPAVEditBox@23@@Z)
2>libfairygui.lib(GTextInput.obj) : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall cocos2d::ui::EditBoxDelegate::editBoxEditingDidEndWithAction(class cocos2d::ui::EditBox *,enum cocos2d::ui::EditBoxDelegate::EditBoxEndAction)" (?editBoxEditingDidEndWithAction@EditBoxDelegate@ui@cocos2d@@UAEXPAVEditBox@23@W4EditBoxEndAction@123@@Z)
2>libfairygui.lib(GearSize.obj) : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) 

你可能感兴趣的:(cocos2d)