win7 64位 cocos2d-x 发生undefined reference to `XX'错误
用vs2012 编译 cocos2d-x-3.0alpha0-pre 项目 没有问题,在Cygwin64 中 gcc 编译 cocos2d-x-3.0alpha0-pre项目时,出现错误
SharedLibrary : libcocos2dcpp.so jni/../../Classes/GameLayer.h:18: error: undefined reference to 'GameLayer::Game Layer()' jni/../../Classes/HudLayer.h:16: error: undefined reference to 'HudLayer::HudLay er()' collect2.exe: error: ld returned 1 exit status /cygdrive/f/yt/application/android-ndk-r9/build/core/build-binary.mk:533: recipe for target 'obj/local/armeabi/libcocos2dcpp.so' failed make: *** [obj/local/armeabi/libcocos2dcpp.so] Error 1 make: Leaving directory '/cygdrive/f/yt/game/cocos2d-x-3.0alpha0-pre/projects/te st/proj.android' |
原因是android的nkd编译需要将每个cpp尽心进行声明
进入jni–>Classes目录下的Android.mk
LOCAL_SRC_FILES := AppDelegate.cpp \ HelloWorldScene.cpp |
在后面跟上你所有的cpp文件
如下
LOCAL_SRC_FILES := hellocpp/main.cpp \ ../../Classes/AppDelegate.cpp \ ../../Classes/GameScene.cpp \ ../../Classes/GameLayer.cpp \ ../../Classes/ActionSprite.cpp \ ../../Classes/Hero.cpp \ ../../Classes/HudLayer.cpp \ ../../Classes/SimpleDPad.cpp |