码迷,mamicode.com
首页 > 移动开发 > 详细

jni/../../Classes/AppDelegate.cpp:102: error: undefined reference to 'TestController::TestController

时间:2014-08-23 17:47:21      阅读:376      评论:0      收藏:0      [点我收藏+]

标签:des   android   style   color   os   使用   io   文件   for   

<1>错误信息:

[armeabi] SharedLibrary  : libcocos2dcpp.so
E:/Android/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/cocos2dcpp_shared/__/__/Classes/AppDelegate.o: in function AppDelegate::applicationDidFinishLaunching():jni/../../Classes/AppDelegate.cpp:102: error: undefined reference to ‘TestController::TestController()‘
collect2: ld returned 1 exit status
make.exe: *** [obj/local/armeabi/libcocos2dcpp.so] Error 1

<2>解决方案

解决问题的方法就是,在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 := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp

LOCAL_SRC_FILES := hellocpp/main.cpp                    ../../Classes/AppDelegate.cpp                    ../../Classes/controller.cpp                    ../../Classes/HelloWorldScene.cpp                    ../../Classes/testBasic.cpp                    ../../Classes/VisibleRect.cpp                    ../../Classes/ActionEaseTest/ActionEaseTest.cpp                    ../../Classes/ActionTest/ActionTest.cpp                    ../../Classes/ClickAndMoveTest/ClickAndMoveTest.cpp                    ../../Classes/NodeTest/NodeTest.cpp                    ../../Classes/TransitionsTest/TransitionsTest.cpp 
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes

LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static
LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static

include $(BUILD_SHARED_LIBRARY)

$(call import-module,cocos2dx)
$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl)
$(call import-module,CocosDenshion/android)
$(call import-module,extensions)
$(call import-module,external/Box2D)
$(call import-module,external/chipmunk)

如果cpp文件太多,加起来就会很麻烦,于是我在网上找到了一种更好的解决方案:

使用下面的Android.mk文件,什么都不用加,就OK了,不管里面有.cpp文件多少编译了

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:102: error: undefined reference to 'TestController::TestController

标签:des   android   style   color   os   使用   io   文件   for   

原文地址:http://blog.csdn.net/u014130695/article/details/38779665

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!