jni/../../Classes/AppDelegate.cpp:102: error: undefined reference to 'TestController::TestController
2014-08-23 17:07
459 查看
<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文件文件:
如果cpp文件太多,加起来就会很麻烦,于是我在网上找到了一种更好的解决方案:
使用下面的Android.mk文件,什么都不用加,就OK了,不管里面有.cpp文件多少编译了。
[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::TestC...
- jni/../../Classes/AppDelegate.cpp:29: error: undefined reference to 'StartLayer。而且没生成libgame.so文件
- jni/../../Classes/AppDelegate.cpp:29: error: undefined reference to 'StartLayer。而且没生成libgame.so文件
- jni/../../Classes/AppDelegate.cpp:29: error: undefined reference to
- Error:ImageIOpng.cpp:(.text+0x5b9): undefined reference to `png_create_write_struct'等
- test.cpp:(.text+0x66): undefined reference to `event_init'
- gcc链接.cpp和.c文件生成的.o库文件的时候,Linking error "undefined reference to `__gxx_personality_v0'"
- 编译linux 内核时:decompress.c:(.text+0x25c4): undefined reference to `error'的解决办法
- gcc编译cpp文件 出现undefined reference to `__gxx_personality_v0'
- NDK编译时,报错error: undefined reference to 'rand',是不是安卓库函数里面没有这个函数的实现呢?
- error:undefined reference to `coloured_LED_init'及相关错误时的解决办法!
- _start:crtbrand.c(.text+0x78): error: undefined reference to 'main'
- Android NDK编译之undefined reference to 'JNI_CreateJavaVM'
- Android NDK编译错误处理-- error: undefined reference to '__dso_handle'
- error:undefined reference to `coloured_LED_init'
- DEV -C++ 中的 [Linker error] undefined reference to `__cpu_features_init' 错误
- Error: undefined reference to `templatename<int,int >' ( error LNK2019: 无法解析的外部符号......)
- FC14下错误 /usr/bin/ld: libvalhalla-test.o: undefined reference to symbol 'clock_gettime@@GLIBC_2.2'
- error fix undefined reference to libiconv_open'
- QT Error undefined reference to `vtable for MyThread'