jni/../../Classes/AppDelegate.cpp:29: error: undefined reference to 'StartLayer。而且没生成libgame.so文件
2014-08-19 23:40
483 查看
分类: cocos2d-x环境搭建常见问题2014-01-23
15:05 304人阅读 评论(0) 收藏 举报
<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)
搞定!!!
plaincopy
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
FILE_LIST := hellocpp/main.cpp
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
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)
15:05 304人阅读 评论(0) 收藏 举报
<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)
搞定!!!
然而最佳解决方案是用下面的Android.mk文件,什么都不用加,就OK了,不管里面有.cpp文件多少编译了。
[plain] viewplaincopy
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
FILE_LIST := hellocpp/main.cpp
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
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)
相关文章推荐
- jni/../../Classes/AppDelegate.cpp:29: error: undefined reference to 'StartLayer。而且没生成libgame.so文件
- jni/../../Classes/AppDelegate.cpp:102: error: undefined reference to 'TestController::TestController
- jni/../../Classes/AppDelegate.cpp:29: error: undefined reference to
- jni/../../Classes/AppDelegate.cpp:102: error: undefined reference to 'TestController::TestC...
- gcc链接.cpp和.c文件生成的.o库文件的时候,Linking error "undefined reference to `__gxx_personality_v0'"
- Error:ImageIOpng.cpp:(.text+0x5b9): undefined reference to `png_create_write_struct'等
- _start:crtbrand.c(.text+0x78): error: undefined reference to 'main'
- crtbegin_dynamic.o: in function _start:crtbrand.c(.text+0x78): error: undefined reference to 'main
- Android NDK编译错误处理-- error: undefined reference to '__dso_handle'
- Error: undefined reference to `templatename<int,int >' ( error LNK2019: 无法解析的外部符号......)
- error fix undefined reference to libiconv_open'
- 编译linux 内核时:decompress.c:(.text+0x25c4): undefined reference to `error'的解决办法
- Linux c++ error: undefined reference to 'dlopen' 解决办法
- register.o: undefined reference to symbol 'gpg_strerror'编译错误的解法
- DEV -C++ 中的 [Linker error] undefined reference to `__cpu_features_init' 错误
- NDK编译时,报错error: undefined reference to 'rand',是不是安卓库函数里面没有这个函数的实现呢?
- Error:undefined reference to '_imp__ZN12QApplicationC1ERiPPci'
- 用gcc编译.cpp文件可能出现"undefined reference to `__gxx_personality_v0'"问题的解决
- gcc编译cpp文件 出现undefined reference to `__gxx_personality_v0'
- gcc 共享库的时候显示.../crt1.o: In function `_start': (.text+0x18): undefined reference to `main'的错误