jni/../../Classes/AppDelegate.cpp:29: error: undefined reference to 'StartLayer。而且没生成libgame.so文件...
<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文件多少编译了。
![](https://code.csdn.net/assets/CODE_ico.png)
- LOCAL_PATH:=$(callmy-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_staticcocosdenshion_staticcocos_extension_static
- include$(BUILD_SHARED_LIBRARY)
- $(callimport-module,CocosDenshion/android)\
- $(callimport-module,cocos2dx)\
- $(callimport-module,extensions)
<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文件多少编译了。
![](https://code.csdn.net/assets/CODE_ico.png)
- LOCAL_PATH:=$(callmy-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_staticcocosdenshion_staticcocos_extension_static
- include$(BUILD_SHARED_LIBRARY)
- $(callimport-module,CocosDenshion/android)\
- $(callimport-module,cocos2dx)\
- $(callimport-module,extensions)
jni/../../Classes/AppDelegate.cpp:29: error: undefined reference to 'StartLayer。而且没生成libgame.so文件...相关推荐
- Qt 多线程bug:moc_widget.cpp:-1: error: undefined reference to `Mythread::~Mythread()‘:-1:
Qt 多线程 moc_widget.cpp:-1: error: undefined reference to `Mythread::~Mythread()' moc_widget.cpp:-1: e ...
- 【Qt】error: undefined reference to `vtable for MainWindow‘
1.问题描述 在写一个demo时,想尽量简单,就把MainWindow类的定义和实现都写在main.cpp中,结果编译时报错: main.cpp:-1: error: undefined refere ...
- 【错误记录】Android NDK 错误排查记录 ( error: undefined reference to | Linking CXX shared library FAILED )
文章目录 一. 报错信息 二. 错误分析 三. 错误总结 一. 报错信息 报错信息 : Build command failed. Error while executing process Y:\0 ...
- android error: undefined reference to 的错误分析
今天,简单讲讲android error: undefined reference to 的错误分析. 昨天,做jni,连接so库时,android studio出现了这个问题.当时不知道是什么 ...
- QT构建编译出现错误error: undefined reference to 的解决办法
这里要解决问题的是QT构建中的 error: undefined reference to 而不是 undefined reference to vtable for "xxx::xxx&q ...
- c++中报错error: undefined reference to `xxx‘
在c++中报错error: undefined reference to `xxx',意思是引用了未定义的方法.造成这个问题有很多原因,这里介绍我遇到的两个问题. 1.未引用对应的头文件或者是在头文件 ...
- error: undefined reference to `calculate()`报错
在调用xx.h和xx.c中的函数,比如calculate()时 如下: #include "xx.h" int t; int result = calculate(t); 此时报错 ...
- 【Qt】报错error: undefined reference to `vtable for的解决方法
1.问题描述 编译Qt程序时,在某个类构造函数定义处报错: error: undefined reference to `vtable for 2.原因分析 导致错误信息的原因是:子类没有实现父类的纯 ...
- 【ffmpeg】编译时报错:error: undefined reference to `av...
1.问题描述 昨天使用ffmpeg库编译demo一切正常,今天再次链接ffmpeg库时报了一堆错误: error: undefined reference to `av_frame_alloc()' ...
最新文章
- oracle bl编译,使用 PL/SQL 条件编译
- 微信界面代码android,仿微信界面代码安卓版
- 无法创建 set/get 参数(参数 ID)
- python 海象运算符,Python3.8新特性-- 海象操作符
- PHP 织梦 帝国那个好,帝国、PHPCMS及织梦对比(十):推荐位功能
- python在职场的用处大吗_Python未来发展怎么样,未来办公是否都需要精通Python?...
- 演示:思科交换机的Telnet管理与SSH管理
- 零售分析用vba还是python_数据分析?Excel、VBA和Python?营销套路还是大势所趋!...
- quick cocos2dx 组件使用要领
- MTK平台CAMERA驱动框架解析
- 计算机软件工程自考,自考软件工程试题及答案2021年10月
- 《剑指offer》之知识汇总
- CNTV视频回看下载地址
- wps里ppt怎么换另一个的模板_现学现用极简技术|智能PPT,一个按键轻松搞定专业的制作!...
- 华为工作十年离职感想
- mysql 未找到 WinSxS_win7的winsxs文件清理方法
- 浙江工商大学计算机技术专硕,浙江工商大学会计专硕(MPAcc)项目介绍
- 以莺尾花数据集为例,探讨R模型部署之道
- Android -窗口小部件开发(App Widgets) 3部分
- java基于微信小程序的共享单车电动车租赁系统 uniapp 小程序