undefined reference to ‘cocos2d::JniHelper::setJavaVM(_JavaVM*)

编译Android的时候遇到这个问题,这是什么原因
hellocpp/main.cpp:18: error: undefined reference to ‘cocos2d::JniHelper::setJavaVM(_JavaVM*)’
hellocpp/main.cpp:24: error: undefined reference to ‘cocos2d::CCDirector::sharedDirector()’

请贴一下 build_native 执行时,最前面几行的输出内容

E:/workspace/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/b
in/…/lib/gcc/arm-linux-androideabi/4.6/…/…/…/…/arm-linux-androideabi/bin/ld
.exe: ./obj/local/armeabi/objs-debug/game_shared/hellocpp/main.o: in function JN
I_OnLoad:jni/hellocpp/main.cpp:18: error: undefined reference to ‘cocos2d::JniHe
lper::setJavaVM(_JavaVM*)’
E:/workspace/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/b
in/…/lib/gcc/arm-linux-androideabi/4.6/…/…/…/…/arm-linux-androideabi/bin/ld
.exe: ./obj/local/armeabi/objs-debug/game_shared/hellocpp/main.o: in function Ja
va_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit:jni/hellocpp/main.cpp:24: error:
undefined reference to ‘cocos2d::CCDirector::sharedDirector()’
E:/workspace/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/b
in/…/lib/gcc/arm-linux-androideabi/4.6/…/…/…/…/arm-linux-androideabi/bin/ld
.exe: ./obj/local/armeabi/objs-debug/game_shared/hellocpp/main.o: in function Ja
va_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit:jni/hellocpp/main.cpp:26: error:
undefined reference to ‘cocos2d::CCEGLView::sharedOpenGLView()’
E:/workspace/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/b
in/…/lib/gcc/arm-linux-androideabi/4.6/…/…/…/…/arm-linux-androideabi/bin/ld
.exe: ./obj/local/armeabi/objs-debug/game_shared/hellocpp/main.o: in function Ja
va_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit:jni/hellocpp/main.cpp:30: error:
undefined reference to ‘cocos2d::CCApplication::sharedApplication()’
E:/workspace/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/b
in/…/lib/gcc/arm-linux-androideabi/4.6/…/…/…/…/arm-linux-androideabi/bin/ld
.exe: ./obj/local/armeabi/objs-debug/game_shared/hellocpp/main.o: in function Ja
va_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit:jni/hellocpp/main.cpp:30: error:

最开头几行,例如:

  • config:
    ANDROID_NDK_ROOT = /Users/dualface/Documents/Games/android/android-ndk-r9b
    QUICK_COCOS2DX_ROOT = /Users/dualface/Documents/Games/quick-cocos2d-x
    COCOS2DX_ROOT = /Users/dualface/Documents/Games/quick-cocos2d-x/lib/cocos2d-x
    APP_ROOT = /Users/dualface/Documents/Games/quick-cocos2d-x/samples/touch/proj.android/…
    APP_ANDROID_ROOT = /Users/dualface/Documents/Games/quick-cocos2d-x/samples/touch/proj.android
  • cleanup
  • copy scripts
  • copy resources

E:\workspace\svn\poker-client\trunk\dzpk\proj.android>build_native.bat

  • config:
    ANDROID_NDK_ROOT = E:\workspace\android\ndk
    QUICK_COCOS2DX_ROOT = E:\workspace\quick-cocos2d-x
    COCOS2DX_ROOT = E:\workspace\quick-cocos2d-x\lib\cocos2d-x
    APP_ROOT = E:\workspace\svn\poker-client\trunk\dzpk\proj.android…

    APP_ANDROID_ROOT = E:\workspace\svn\poker-client\trunk\dzpk\proj.android\
  • cleanup
  • copy scripts
    复制了 29 个文件
  • copy resources
    复制了 143 个文件
    Using prebuilt externals
    make: Entering directory `E:/workspace/svn/poker-client/trunk/dzpk/proj.android’

Gdbserver : libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
SharedLibrary : libgame.so
E:/workspace/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/b

你用 bin/create_project 新建一个项目来编译试试看。如果新项目没问题,那就把你老项目里的res/scripts复制过去就好了。

问题解决了,我用的quick2.2.3,ndk用的r8,2.2.3不支持r8,换成r9就好了

我的ndk 换成r9还是有这个错误。 朋友还有其它解决办法没