Date: 2015/2/18 Cate: Android, cocos2d-x Tags: , ,  

cocos2d-xのv3.2を使って開発をしていて、cocos run -p androidでAndroidの実機で動かそうとしたところ、以下の様なエラーがでました。


[armeabi] StaticLibrary  : libcpufeatures.a
[armeabi] SharedLibrary  : libcocos2dcpp.so
./obj/local/armeabi/objs-debug/cocos2dcpp_shared/__/__/Classes/FoodSprite.o:jni/../../Classes/FoodSprite.cpp:function vtable for FoodSprite: error: undefined reference to 'cocos2d::Sprite::setDisplayFrameWithAnimationName(std::__1::basic_string, std::__1::allocator > const&, long)'
./obj/local/armeabi/objs-debug/cocos2dcpp_shared/__/__/Classes/PanSprite.o:jni/../../Classes/PanSprite.cpp:function vtable for PanSprite: error: undefined reference to 'cocos2d::Sprite::setDisplayFrameWithAnimationName(std::__1::basic_string, std::__1::allocator > const&, long)'
./obj/local/armeabi/objs-debug/cocos2dcpp_shared/__/__/Classes/RecipeSprite.o:jni/../../Classes/RecipeSprite.cpp:function vtable for RecipeSprite: error: undefined reference to 'cocos2d::Sprite::setDisplayFrameWithAnimationName(std::__1::basic_string, std::__1::allocator > const&, long)'
./obj/local/armeabi/objs-debug/cocos2dcpp_shared/__/__/Classes/StoveSprite.o:jni/../../Classes/StoveSprite.cpp:function vtable for StoveSprite: error: undefined reference to 'cocos2d::Sprite::setDisplayFrameWithAnimationName(std::__1::basic_string, std::__1::allocator > const&, long)'
jni/../../cocos2d/cocos/./2d/CCAtlasNode.cpp:138: error: undefined reference to 'cocos2d::QuadCommand::init(float, unsigned int, cocos2d::GLProgramState*, cocos2d::BlendFunc, cocos2d::V3F_C4B_T2F_Quad*, int, cocos2d::Mat4 const&)'
jni/../../cocos2d/cocos/./2d/CCDrawingPrimitives.cpp:500: error: undefined reference to 'cocos2d::PointArray::getControlPointAtIndex(int)'
jni/../../cocos2d/cocos/./2d/CCDrawingPrimitives.cpp:501: error: undefined reference to 'cocos2d::PointArray::getControlPointAtIndex(int)'
jni/../../cocos2d/cocos/./2d/CCDrawingPrimitives.cpp:502: error: undefined reference to 'cocos2d::PointArray::getControlPointAtIndex(int)'
jni/../../cocos2d/cocos/./2d/CCDrawingPrimitives.cpp:503: error: undefined reference to 'cocos2d::PointArray::getControlPointAtIndex(int)'
jni/../../cocos2d/cocos/./2d/CCParticleExamples.cpp:52: error: undefined reference to 'cocos2d::Image::initWithImageData(unsigned char const*, int)'
jni/../../cocos2d/cocos/./2d/CCParticleSystem.cpp:403: error: undefined reference to 'cocos2d::ZipUtils::inflateMemory(unsigned char*, int, unsigned char**)'
jni/../../cocos2d/cocos/./2d/CCParticleSystem.cpp:409: error: undefined reference to 'cocos2d::Image::initWithImageData(unsigned char const*, int)'
jni/../../cocos2d/cocos/./2d/CCParticleSystemQuad.cpp:377: error: undefined reference to 'cocos2d::QuadCommand::init(float, unsigned int, cocos2d::GLProgramState*, cocos2d::BlendFunc, cocos2d::V3F_C4B_T2F_Quad*, int, cocos2d::Mat4 const&)'
jni/../../cocos2d/cocos/./2d/CCRenderTexture.cpp:526: error: undefined reference to 'cocos2d::Image::initWithRawData(unsigned char const*, int, int, int, int, bool)'
jni/../../cocos2d/cocos/./2d/CCRenderTexture.cpp:530: error: undefined reference to 'cocos2d::Image::initWithRawData(unsigned char const*, int, int, int, int, bool)'
jni/../../cocos2d/cocos/./2d/CCSprite.cpp:336: error: undefined reference to 'cocos2d::Image::initWithRawData(unsigned char const*, int, int, int, int, bool)'
jni/../../cocos2d/cocos/./2d/CCSprite.cpp:595: error: undefined reference to 'cocos2d::QuadCommand::init(float, unsigned int, cocos2d::GLProgramState*, cocos2d::BlendFunc, cocos2d::V3F_C4B_T2F_Quad*, int, cocos2d::Mat4 const&)'
jni/../../cocos2d/cocos/./2d/CCTMXLayer.cpp:91: error: undefined reference to 'cocos2d::ccCArrayNew(int)'
jni/../../cocos2d/cocos/./2d/CCTMXLayer.cpp:448: error: undefined reference to 'cocos2d::ccCArrayInsertValueAtIndex(cocos2d::_ccCArray*, void*, int)'
jni/../../cocos2d/cocos/./2d/CCTMXLayer.cpp:384: error: undefined reference to 'cocos2d::ccCArrayInsertValueAtIndex(cocos2d::_ccCArray*, void*, int)'
jni/../../cocos2d/cocos/./2d/CCTMXLayer.cpp:585: error: undefined reference to 'cocos2d::ccCArrayRemoveValueAtIndex(cocos2d::_ccCArray*, int)'
jni/../../cocos2d/cocos/./2d/CCTMXLayer.cpp:565: error: undefined reference to 'cocos2d::ccCArrayRemoveValueAtIndex(cocos2d::_ccCArray*, int)'
jni/../../cocos2d/cocos/./2d/CCTMXXMLParser.cpp:646: error: undefined reference to 'cocos2d::ZipUtils::inflateMemoryWithHint(unsigned char*, int, unsigned char**, int)'
jni/../../cocos2d/cocos/./platform/CCFileUtils.cpp:560: error: undefined reference to 'cocos2d::Data::fastSet(unsigned char*, int)'
jni/../../cocos2d/cocos/./base/CCDirector.cpp:1146: error: undefined reference to 'cocos2d::Image::initWithImageData(unsigned char const*, int)'
jni/../../cocos2d/cocos/./base/CCScheduler.cpp:1100: error: undefined reference to 'cocos2d::ccArrayRemoveObjectAtIndex(cocos2d::_ccArray*, int, bool)'
jni/../../cocos2d/cocos/./base/CCScheduler.cpp:360: error: undefined reference to 'cocos2d::ccArrayRemoveObjectAtIndex(cocos2d::_ccArray*, int, bool)'
jni/../../cocos2d/cocos/./base/CCScheduler.cpp:308: error: undefined reference to 'cocos2d::ccArrayNew(int)'
jni/../../cocos2d/cocos/./base/CCScheduler.cpp:323: error: undefined reference to 'cocos2d::ccArrayEnsureExtraCapacity(cocos2d::_ccArray*, int)'
jni/../../cocos2d/cocos/./base/CCScheduler.cpp:1008: error: undefined reference to 'cocos2d::ccArrayNew(int)'
jni/../../cocos2d/cocos/./base/CCScheduler.cpp:1023: error: undefined reference to 'cocos2d::ccArrayEnsureExtraCapacity(cocos2d::_ccArray*, int)'
jni/../../cocos2d/cocos/./base/ccUtils.cpp:125: error: undefined reference to 'cocos2d::Image::initWithRawData(unsigned char const*, int, int, int, int, bool)'
jni/../../cocos2d/cocos/./renderer/CCTextureCache.cpp:730: error: undefined reference to 'cocos2d::Image::initWithImageData(unsigned char const*, int)'
./obj/local/armeabi/libcocos2dandroid.a(CCFileUtilsAndroid.o):/Users/keishake/Documents/SELECTBUTTON/projects/HuntCook/HuntCook/proj.android/../cocos2d/cocos/platform/android/CCFileUtilsAndroid.cpp:function vtable for cocos2d::FileUtilsAndroid: error: undefined reference to 'cocos2d::FileUtils::getFileDataFromZip(std::__1::basic_string, std::__1::allocator > const&, std::__1::basic_string, std::__1::allocator > const&, long*)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [obj/local/armeabi/libcocos2dcpp.so] Error 1
make: Leaving directory `/Users/keishake/Documents/SELECTBUTTON/projects/HuntCook/HuntCook/proj.android'
Error running command, return code: 2


cocos run -p android -m debug --ndk-mode NDK_DEBUG=1で実行するとエラーが出ずに実行できたのですが、どうも過去に別のcocos2-cのバージョンでビルドしようとした時の一時ファイルが残って邪魔してるんじゃないかと。

ということで、proj.androidディレクトリ以下で./build_native.py -n cleanを実行するとAndroid環境でのCleanが実行できるようなので、それで一度Cleanしてからcocos run -p androidを実行したらうまくいきました。

やっぱり別のバージョンでコンパイルしたファイルとかが残ってて邪魔してたっぽいですね。気をつけよう。

Leave a Reply