[SOLVED] Cocos2d-x 3.2 "error: undefined reference to"

I am using Cocos2d-x 3.2, ndk r9d, the last version of Cocos IDE and I created a new project, just a new project, a sample project, nothing more, but when I try to build APK:

Android NDK: WARNING:C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries    
Android NDK: WARNING:C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//platform/android/Android.mk:cocos2dxandroid_static: LOCAL_LDLIBS is always ignored for static libraries    
make.exe: Entering directory `C:/Users/Admin/Desktop/Gota/Gota/frameworks/runtime-src/proj.android'
[armeabi] StaticLibrary  : liblua.a
[armeabi] StaticLibrary  : libnetwork.a
[armeabi] StaticLibrary  : libcocosbuilder.a
[armeabi] StaticLibrary  : libcocostudio.a
[armeabi] StaticLibrary  : libspine.a
[armeabi] StaticLibrary  : libui.a
[armeabi] StaticLibrary  : libextension.a
[armeabi] StaticLibrary  : libcocos2d.a
[armeabi] StaticLibrary  : libcocosdenshion.a
[armeabi] StaticLibrary  : libbox2d.a
[armeabi] StaticLibrary  : libchipmunk.a
[armeabi] StaticLibrary  : libcocos2dandroid.a
[armeabi] StaticLibrary  : libcpufeatures.a
[armeabi] SharedLibrary  : libcocos2dlua.so
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//scripting/lua-bindings/manual/LuaBasicConversions.cpp:1096: error: undefined reference to 'cocos2d::__Array::createWithCapacity(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//scripting/lua-bindings/manual/lua_cocos2dx_deprecated.cpp:594: error: undefined reference to 'cocos2d::__Array::createWithCapacity(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//scripting/lua-bindings/manual/lua_cocos2dx_deprecated.cpp:997: error: undefined reference to 'cocos2d::__Array::insertObject(cocos2d::Ref*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//scripting/lua-bindings/manual/lua_cocos2dx_deprecated.cpp:1099: error: undefined reference to 'cocos2d::__Array::removeObjectAtIndex(int, bool)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//scripting/lua-bindings/manual/lua_cocos2dx_deprecated.cpp:1225: error: undefined reference to 'cocos2d::__Array::fastRemoveObjectAtIndex(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//scripting/lua-bindings/manual/lua_cocos2dx_deprecated.cpp:1294: error: undefined reference to 'cocos2d::__Array::exchangeObjectAtIndex(int, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//scripting/lua-bindings/manual/lua_cocos2dx_deprecated.cpp:1393: error: undefined reference to 'cocos2d::__Array::replaceObjectAtIndex(int, cocos2d::Ref*, bool)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//editor-support/cocostudio/CCSkin.cpp:201: error: undefined reference to 'cocos2d::TextureAtlas::updateQuad(cocos2d::V3F_C4B_T2F_Quad*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//editor-support/cocostudio/CCSkin.cpp:228: error: undefined reference to 'cocos2d::QuadCommand::init(float, unsigned int, cocos2d::GLProgramState*, cocos2d::BlendFunc, cocos2d::V3F_C4B_T2F_Quad*, int, cocos2d::Mat4 const&)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//editor-support/cocostudio/CCDataReaderHelper.cpp:430: error: undefined reference to 'cocos2d::Data::copy(unsigned char*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//editor-support/spine/CCSkeleton.cpp:184: error: undefined reference to 'cocos2d::TextureAtlas::resizeCapacity(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//editor-support/spine/CCSkeleton.cpp:188: error: undefined reference to 'cocos2d::TextureAtlas::updateQuad(cocos2d::V3F_C4B_T2F_Quad*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//editor-support/spine/spine-cocos2dx.cpp:41: error: undefined reference to 'cocos2d::TextureAtlas::createWithTexture(cocos2d::Texture2D*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCActionManager.cpp:81: error: undefined reference to 'cocos2d::ccArrayNew(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCActionManager.cpp:100: error: undefined reference to 'cocos2d::ccArrayRemoveObjectAtIndex(cocos2d::_ccArray*, int, bool)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCAtlasNode.cpp:93: error: undefined reference to 'cocos2d::TextureAtlas::initWithTexture(cocos2d::Texture2D*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/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&)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCFontAtlas.cpp:76: error: undefined reference to 'cocos2d::Texture2D::initWithData(void const*, int, cocos2d::Texture2D::PixelFormat, int, int, cocos2d::Size const&)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCFontAtlas.cpp:268: error: undefined reference to 'cocos2d::Texture2D::initWithData(void const*, int, cocos2d::Texture2D::PixelFormat, int, int, cocos2d::Size const&)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCFontAtlas.cpp:312: error: undefined reference to 'cocos2d::Texture2D::initWithData(void const*, int, cocos2d::Texture2D::PixelFormat, int, int, cocos2d::Size const&)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCGrid.cpp:133: error: undefined reference to 'cocos2d::Texture2D::initWithData(void const*, int, cocos2d::Texture2D::PixelFormat, int, int, cocos2d::Size const&)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCLabel.cpp:1326: error: undefined reference to 'cocos2d::TextureAtlas::updateQuad(cocos2d::V3F_C4B_T2F_Quad*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCLabelAtlas.cpp:208: error: undefined reference to 'cocos2d::TextureAtlas::increaseTotalQuadsWith(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCLabelAtlas.cpp:219: error: undefined reference to 'cocos2d::TextureAtlas::resizeCapacity(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCLabelAtlas.cpp:250: error: undefined reference to 'cocos2d::TextureAtlas::updateQuad(cocos2d::V3F_C4B_T2F_Quad*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParallaxNode.cpp:68: error: undefined reference to 'cocos2d::ccArrayNew(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParallaxNode.cpp:126: error: undefined reference to 'cocos2d::ccArrayRemoveObjectAtIndex(cocos2d::_ccArray*, int, bool)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParticleBatchNode.cpp:100: error: undefined reference to 'cocos2d::TextureAtlas::initWithTexture(cocos2d::Texture2D*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParticleBatchNode.cpp:433: error: undefined reference to 'cocos2d::TextureAtlas::resizeCapacity(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParticleBatchNode.cpp:459: error: undefined reference to 'cocos2d::TextureAtlas::fillWithEmptyQuadsFromIndex(int, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParticleBatchNode.cpp:465: error: undefined reference to 'cocos2d::TextureAtlas::moveQuadsFromIndex(int, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParticleBatchNode.cpp:469: error: undefined reference to 'cocos2d::TextureAtlas::increaseTotalQuadsWith(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParticleBatchNode.cpp:291: error: undefined reference to 'cocos2d::TextureAtlas::moveQuadsFromIndex(int, int, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParticleBatchNode.cpp:379: error: undefined reference to 'cocos2d::TextureAtlas::removeQuadsAtIndex(int, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParticleBatchNode.cpp:382: error: undefined reference to 'cocos2d::TextureAtlas::fillWithEmptyQuadsFromIndex(int, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParticleBatchNode.cpp:433: error: undefined reference to 'cocos2d::TextureAtlas::resizeCapacity(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParticleExamples.cpp:52: error: undefined reference to 'cocos2d::Image::initWithImageData(unsigned char const*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParticleSystem.cpp:403: error: undefined reference to 'cocos2d::ZipUtils::inflateMemory(unsigned char*, int, unsigned char**)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCParticleSystem.cpp:409: error: undefined reference to 'cocos2d::Image::initWithImageData(unsigned char const*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/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&)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCRenderTexture.cpp:526: error: undefined reference to 'cocos2d::Image::initWithRawData(unsigned char const*, int, int, int, int, bool)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCRenderTexture.cpp:530: error: undefined reference to 'cocos2d::Image::initWithRawData(unsigned char const*, int, int, int, int, bool)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCSprite.cpp:336: error: undefined reference to 'cocos2d::Image::initWithRawData(unsigned char const*, int, int, int, int, bool)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/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&)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCSpriteBatchNode.cpp:99: error: undefined reference to 'cocos2d::TextureAtlas::initWithTexture(cocos2d::Texture2D*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCSpriteBatchNode.cpp:548: error: undefined reference to 'cocos2d::TextureAtlas::insertQuad(cocos2d::V3F_C4B_T2F_Quad*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCSpriteBatchNode.cpp:560: error: undefined reference to 'cocos2d::TextureAtlas::removeQuadAtIndex(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCSpriteBatchNode.cpp:639: error: undefined reference to 'cocos2d::TextureAtlas::insertQuad(cocos2d::V3F_C4B_T2F_Quad*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCTMXLayer.cpp:91: error: undefined reference to 'cocos2d::ccCArrayNew(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCTMXLayer.cpp:448: error: undefined reference to 'cocos2d::ccCArrayInsertValueAtIndex(cocos2d::_ccCArray*, void*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCTMXLayer.cpp:384: error: undefined reference to 'cocos2d::ccCArrayInsertValueAtIndex(cocos2d::_ccCArray*, void*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCTMXLayer.cpp:585: error: undefined reference to 'cocos2d::ccCArrayRemoveValueAtIndex(cocos2d::_ccCArray*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCTMXLayer.cpp:595: error: undefined reference to 'cocos2d::TextureAtlas::removeQuadAtIndex(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCTMXLayer.cpp:565: error: undefined reference to 'cocos2d::ccCArrayRemoveValueAtIndex(cocos2d::_ccCArray*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCTMXXMLParser.cpp:646: error: undefined reference to 'cocos2d::ZipUtils::inflateMemoryWithHint(unsigned char*, int, unsigned char**, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./2d/CCTileMapAtlas.cpp:226: error: undefined reference to 'cocos2d::TextureAtlas::increaseTotalQuadsWith(int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./3d/CCBundle3D.cpp:451: error: undefined reference to 'cocos2d::BundleReader::init(char*, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./3d/CCBundle3D.cpp:456: error: undefined reference to 'cocos2d::BundleReader::read(void*, int, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./3d/CCBundle3D.cpp:465: error: undefined reference to 'cocos2d::BundleReader::read(void*, int, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./3d/CCBundle3D.cpp:484: error: undefined reference to 'cocos2d::BundleReader::read(void*, int, int)'
C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos//./3d/CCBundle3D.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 invocation)
make.exe: *** [obj/local/armeabi/libcocos2dlua.so] Error 1
make.exe: Leaving directory `C:/Users/Admin/Desktop/Gota/Gota/frameworks/runtime-src/proj.android'
Running command: compile
Building mode: debug
building native
NDK build mode: release
The Selected NDK toolchain version was 4.8 !
running: 'C:\android\ndk3\ndk-build -C C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android -j3 NDK_MODULE_PATH=C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x;C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos/;C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/external;C:\Users\Admin\Desktop\Gota\Gota\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos/scripting'

Error running command, return code: 2

If someone wants to know how I solved it:
The problem was in the situation of the folder, if it is not in the workspace folder (documents/cocos/…) gives this error.

hi, i meet this problem too, but i don’t understand how did you solve it, can you say more clearly, please !

1 Like

When you create a project, it gives you a default folder, situated in C:\Users\you\documents\cocos, I didn’t used this folder (I changed for another) and that’s why I get this error, I created one new in the default and it goes well.

thanks, i will check my project.

build success!
my situation is different: i builded it with ndk-r10b and failed at the beginning, i find that it is a bug of ndk-r10b, so use ndk-r9d instead, but forgetting clean up the project.

clean up, must clean up. it took me 2 days to solve it. never forget clean up.

I am trying to compile my cocos2dx project (running ok on iOS platform) to android platform
my project uses cocos2dx v3.8 and is running with no problems on iOS
but I am getting “error: undefined reference to” error
checked briefly online it is a linker probe usually coz of typo on function name
checked my function name there’s no mis-spellings

I am on Mac and don’t seem to be able to find the mentioned folder (user/useName/documents/cocos/)

and how can i clean up with cosos console ? I don’t see any clean up commands there
http://www.cocos2d-x.org/wiki/Cocos2d-console

thx in advanced