<1>报错。
G:/AndroidCocos2dxFile/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/game_shared/__/__/Classes/AppDelegate.o: in function AppDelegate::applicationDidFinishLaunching():jni/../../Classes/AppDelegate.cpp:29: error: undefined reference to 'StartLayer::scene()'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libgame.so] Error 1
<2>解决方案。
这个问题困扰了我快一天,因为以前运行别人的工程是没有问题的,还以为没有加上main.h和main.cpp导致的。
解决问题的方法就是,在Android.mk中:
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp \
在后面加上要编译的.cpp文件文件
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp \
../../Classes/StartLayer.cpp \
../../Classes/BasicLayer.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,CocosDenshion/android) \
$(call import-module,cocos2dx) \
$(call import-module,extensions)
搞定!!!