cocos2d-x3.2打包apk時出現undefined reference to "cocos2d::xxxxx"錯誤

出現如下錯誤:
./obj/local/armeabi/objs-debug/cocos2dcpp_shared///Classes/Cat.o:jni/…/…/C
lasses/Cat.cpp:function vtable for Cat: error: undefined reference to ‘cocos2d::
Sprite::setDisplayFrameWithAnimationName(std::__1::basic_string<char, std::__1::
char_traits, std::__1::allocator > const&, long)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/editor-supp
ort/spine/spine-cocos2dx.cpp:41: error: undefined reference to ‘cocos2d::Texture
Atlas::createWithTexture(cocos2d::Texture2D*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/editor-supp
ort/cocostudio/CCSkin.cpp:201: error: undefined reference to ‘cocos2d::TextureAt
las::updateQuad(cocos2d::V3F_C4B_T2F_Quad*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/editor-supp
ort/cocostudio/CCSkin.cpp:228: error: undefined reference to ‘cocos2d::QuadComma
nd::init(float, unsigned int, cocos2d::GLProgramState*, cocos2d::BlendFunc, coco
s2d::V3F_C4B_T2F_Quad*, int, cocos2d::Mat4 const&)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCActi
onManager.cpp:81: error: undefined reference to ‘cocos2d::ccArrayNew(int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCActi
onManager.cpp:100: error: undefined reference to ‘cocos2d::ccArrayRemoveObjectAt
Index(cocos2d::_ccArray*, int, bool)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCAtla
sNode.cpp:93: error: undefined reference to ‘cocos2d::TextureAtlas::initWithText
ure(cocos2d::Texture2D*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCAtla
sNode.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&)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCFont
Atlas.cpp:76: error: undefined reference to 'cocos2d::Texture2D::initWithData(vo
id const*, int, cocos2d::Texture2D::PixelFormat, int, int, cocos2d::Size const&)

E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCFont
Atlas.cpp:268: error: undefined reference to ‘cocos2d::Texture2D::initWithData(v
oid const*, int, cocos2d::Texture2D::PixelFormat, int, int, cocos2d::Size const&
)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCFont
Atlas.cpp:312: error: undefined reference to ‘cocos2d::Texture2D::initWithData(v
oid const*, int, cocos2d::Texture2D::PixelFormat, int, int, cocos2d::Size const&
)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCGrid
.cpp:133: error: undefined reference to ‘cocos2d::Texture2D::initWithData(void c
onst*, int, cocos2d::Texture2D::PixelFormat, int, int, cocos2d::Size const&)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCLabe
l.cpp:1326: error: undefined reference to ‘cocos2d::TextureAtlas::updateQuad(coc
os2d::V3F_C4B_T2F_Quad*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCLabe
lAtlas.cpp:208: error: undefined reference to ‘cocos2d::TextureAtlas::increaseTo
talQuadsWith(int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCLabe
lAtlas.cpp:219: error: undefined reference to ‘cocos2d::TextureAtlas::resizeCapa
city(int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCLabe
lAtlas.cpp:250: error: undefined reference to ‘cocos2d::TextureAtlas::updateQuad
(cocos2d::V3F_C4B_T2F_Quad*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPara
llaxNode.cpp:68: error: undefined reference to ‘cocos2d::ccArrayNew(int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPara
llaxNode.cpp:126: error: undefined reference to ‘cocos2d::ccArrayRemoveObjectAtI
ndex(cocos2d::_ccArray*, int, bool)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPart
icleBatchNode.cpp:100: error: undefined reference to ‘cocos2d::TextureAtlas::ini
tWithTexture(cocos2d::Texture2D*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPart
icleBatchNode.cpp:459: error: undefined reference to ‘cocos2d::TextureAtlas::fil
lWithEmptyQuadsFromIndex(int, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPart
icleBatchNode.cpp:465: error: undefined reference to ‘cocos2d::TextureAtlas::mov
eQuadsFromIndex(int, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPart
icleBatchNode.cpp:469: error: undefined reference to ‘cocos2d::TextureAtlas::inc
reaseTotalQuadsWith(int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPart
icleBatchNode.cpp:291: error: undefined reference to ‘cocos2d::TextureAtlas::mov
eQuadsFromIndex(int, int, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPart
icleBatchNode.cpp:379: error: undefined reference to ‘cocos2d::TextureAtlas::rem
oveQuadsAtIndex(int, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPart
icleBatchNode.cpp:382: error: undefined reference to ‘cocos2d::TextureAtlas::fil
lWithEmptyQuadsFromIndex(int, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPart
icleBatchNode.cpp:433: error: undefined reference to ‘cocos2d::TextureAtlas::res
izeCapacity(int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPart
icleExamples.cpp:52: error: undefined reference to ‘cocos2d::Image::initWithImag
eData(unsigned char const*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPart
icleSystem.cpp:403: error: undefined reference to ‘cocos2d::ZipUtils::inflateMem
ory(unsigned char*, int, unsigned char**)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPart
icleSystem.cpp:409: error: undefined reference to ‘cocos2d::Image::initWithImage
Data(unsigned char const*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCPart
icleSystemQuad.cpp:377: error: undefined reference to ‘cocos2d::QuadCommand::ini
t(float, unsigned int, cocos2d::GLProgramState*, cocos2d::BlendFunc, cocos2d::V3
F_C4B_T2F_Quad*, int, cocos2d::Mat4 const&)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCRend
erTexture.cpp:526: error: undefined reference to ‘cocos2d::Image::initWithRawDat
a(unsigned char const*, int, int, int, int, bool)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCRend
erTexture.cpp:530: error: undefined reference to ‘cocos2d::Image::initWithRawDat
a(unsigned char const*, int, int, int, int, bool)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCSpri
te.cpp:336: error: undefined reference to ‘cocos2d::Image::initWithRawData(unsig
ned char const*, int, int, int, int, bool)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCSpri
te.cpp:568: error: undefined reference to ‘cocos2d::TextureAtlas::updateQuad(coc
os2d::V3F_C4B_T2F_Quad*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCSpri
te.cpp:595: error: undefined reference to ‘cocos2d::QuadCommand::init(float, uns
igned int, cocos2d::GLProgramState*, cocos2d::BlendFunc, cocos2d::V3F_C4B_T2F_Qu
ad*, int, cocos2d::Mat4 const&)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCSpri
teBatchNode.cpp:99: error: undefined reference to ‘cocos2d::TextureAtlas::initWi
thTexture(cocos2d::Texture2D*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCSpri
teBatchNode.cpp:548: error: undefined reference to ‘cocos2d::TextureAtlas::inser
tQuad(cocos2d::V3F_C4B_T2F_Quad*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCSpri
teBatchNode.cpp:560: error: undefined reference to ‘cocos2d::TextureAtlas::remov
eQuadAtIndex(int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCSpri
teBatchNode.cpp:405: error: undefined reference to ‘cocos2d::TextureAtlas::resiz
eCapacity(int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCSpri
teBatchNode.cpp:639: error: undefined reference to ‘cocos2d::TextureAtlas::inser
tQuad(cocos2d::V3F_C4B_T2F_Quad*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCTMXL
ayer.cpp:91: error: undefined reference to ‘cocos2d::ccCArrayNew(int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCTMXL
ayer.cpp:448: error: undefined reference to ‘cocos2d::ccCArrayInsertValueAtIndex
(cocos2d::_ccCArray*, void*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCTMXL
ayer.cpp:384: error: undefined reference to ‘cocos2d::ccCArrayInsertValueAtIndex
(cocos2d::_ccCArray*, void*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCTMXL
ayer.cpp:585: error: undefined reference to ‘cocos2d::ccCArrayRemoveValueAtIndex
(cocos2d::_ccCArray*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCTMXL
ayer.cpp:595: error: undefined reference to ‘cocos2d::TextureAtlas::removeQuadAt
Index(int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCTMXL
ayer.cpp:565: error: undefined reference to ‘cocos2d::ccCArrayRemoveValueAtIndex
(cocos2d::_ccCArray*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCTMXX
MLParser.cpp:646: error: undefined reference to ‘cocos2d::ZipUtils::inflateMemor
yWithHint(unsigned char*, int, unsigned char**, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./2d/CCTile
MapAtlas.cpp:226: error: undefined reference to ‘cocos2d::TextureAtlas::increase
TotalQuadsWith(int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/editor-supp
ort/spine/CCSkeleton.cpp:184: error: undefined reference to ‘cocos2d::TextureAtl
as::resizeCapacity(int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/editor-supp
ort/cocostudio/CCDataReaderHelper.cpp:430: error: undefined reference to ‘cocos2
d::Data::copy(unsigned char*, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./3d/CCBund
le3D.cpp:451: error: undefined reference to ‘cocos2d::BundleReader::init(char*,
int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./3d/CCBund
le3D.cpp:456: error: undefined reference to ‘cocos2d::BundleReader::read(void*,
int, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./3d/CCBund
le3D.cpp:465: error: undefined reference to ‘cocos2d::BundleReader::read(void*,
int, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./3d/CCBund
le3D.cpp:484: error: undefined reference to ‘cocos2d::BundleReader::read(void*,
int, int)’
E:\MyFiles\Projects\Cat_whack\catWhack\proj.android…/cocos2d/cocos/./3d/CCBund
le3D.cpp:497: error: undefined reference to ‘cocos2d::BundleReader::read(void*,
int, int)’
clang++.exe: error: linker command failed with exit code 1 (use -v to see invoca
tion)
make.exe: *** Error 1
make.exe: Leaving directory `E:/MyFiles/Projects/Cat_whack/catWhack/proj.android

Error running command, return code: 2

android.mk的設置如下:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

(call import-add-path,(LOCAL_PATH)/…/…/cocos2d)
(call import-add-path,(LOCAL_PATH)/…/…/cocos2d/external)
(call import-add-path,(LOCAL_PATH)/…/…/cocos2d/cocos)

LOCAL_MODULE := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp

LOCAL_SRC_FILES := hellocpp/main.cpp
…/…/Classes/AppDelegate.cpp
…/…/Classes/HelloWorldScene.cpp
…/…/Classes/Cat.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/Classes

LOCAL_C_INCLUDES += (LOCAL_PATH)/../../cocos2d/extensions \ (LOCAL_PATH)/…/…/cocos2d/cocos/editor-support/cocostudio
$(LOCAL_PATH)/…/…/cocos2d/cocos/ui

LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static

LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_static
LOCAL_WHOLE_STATIC_LIBRARIES += spine_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static

include $(BUILD_SHARED_LIBRARY)

(call import-module,.) (call import-module,audio/android)

(call import-module,Box2D) (call import-module,editor-support/cocosbuilder)
(call import-module,editor-support/spine) (call import-module,editor-support/cocostudio)
(call import-module,network) (call import-module,extensions)
(call import-module,audio/android) (call import-module,ui)

究竟錯在哪?:6:

解决了吗?我也遇到这样的情况啊

工程目录的问题,需要修改android.mk文件

楼主解决了吗??我也遇到undefinde reference to cocos2d::xxxxxx 求告诉啊 谢谢:11:

解决了吗?

Cocos2dx3.2的版本,在…cocos/3d/CCBunldeReader的.h和.cpp文件中函数 long int tell(); 在cpp中是 ssixe_t tell(); 其实都是对的,但是在打包apk时会遇到问题,所以你讲 long int tell() 改为ssize_t tell(); 就可以了。至于前面的是你需要自己在.mk 文件中加入你自己编写的cpp文件