- 浏览: 382822 次
最新评论
-
qq_19471875:
为了感谢楼主 我特意注册了一个账号!,谢谢!很实用!真棒
ViewPager刷新单个页面的方法 -
asdf658:
...
Eclipse安装server插件 -
JasonMichael:
多谢。搞定~
Eclipse安装server插件 -
passerby_whu:
应该是官网写错了。应该是144x144.
Android不太能够分辨率launcher icon的适配 -
zhengyong7232:
Create or replace function test ...
postgresql产生随机数和随机日期的存储过程
Cocos2dx开发解决undefined reference to 'atof'和x86平台下报internal compiler error的错误
- 博客分类:
- Android开发
最近在为游戏做java sdk的cocos2dx引擎层代码时遇到两个问题:
1.游戏安装后无法在老设备(4.4)上运行,6.0没问题。crash信息为:
有两种表现,有可能是编译.so文件通过,但是在老设备上运行就crash,或者还有就是编译.so文件时直接提示上面的错误信息,无论哪种解决方法都一样,请设置APP_PLATFORM := android-19(或者更早的),因为google从android-21开始将以上那几个函数放到l.cpp文件里面去了,而之前是放在.h文件中的,而ndk和其他sdk不一样,它是向前兼容(Forwards Compatibility)的,也就是老版本兼容新版本,但新版本不兼容老版本,我们在使用jdk或者android sdk编译时总是喜欢用最新的版本编译,但是ndk编译时请使用老版本编译,其实最理想的状态是ndk的APP_PLATFORM应该等于manifest中的minSdkVersion的值,之前我一直使用android-23编译,才导致了这个问题;
stackoverflow上有人这么解释:
Google have moved some of the C standard library functions like atof() from being inline functions in header files to normal functions. The latest NDKs will default to building a .so that is only compatible with the latest Android devices that have the atof() function in the device's standard C library (libc.so). This means if you run a library on an older device that has an older version of the C library, you will get an error loading the dll as the expected atof() function will not exist.
如果还是不行,可能你需要将上面那些报错的文件都检查一遍,如果哪个文件没有包含头文件#include <stdlib.h>,请自行添加(我是添加过的)。
好了,这个问题应该解决了,在armeabi和armeabi-v7a下面正常编译除了.so,并且老设备也正常运行,可是当我编译x86时,失败了,这就是下面要说的第2个问题。
2.在x86平台下编译so文件失败,提示信息如下
首先要说明一下我的开发和编译环境:MacOS X + clang,并且使用了c++11的一些新特性,比如lambda表达式,只要程序运行到lambda表达式就crash,最后查出来需要将APP_STL改为c++_static就可以了,既能编译x86架构又不会crash:
1.游戏安装后无法在老设备(4.4)上运行,6.0没问题。crash信息为:
xxx/proj.android/../cocos2d/cocos/./platform/CCFileUtils.cpp:277: error: undefined reference to 'atof' xxx/proj.android/../cocos2d/cocos/./platform/CCFileUtils.cpp:286: error: undefined reference to 'atof' xxx/proj.android/../cocos2d/cocos/./base/CCConsole.cpp:1224: error: undefined reference to 'srand' xxx/proj.android/../cocos2d/cocos/./base/CCConsole.cpp:1225: error: undefined reference to 'rand' xxx/proj.android/../cocos2d/cocos/./base/CCConsole.cpp:1253: error: undefined reference to 'srand' xxx/proj.android/../cocos2d/cocos/./base/CCConsole.cpp:1254: error: undefined reference to 'rand' xxx/proj.android/../cocos2d/cocos/./base/ccUtils.cpp:254: error: undefined reference to 'atof' xxx/proj.android/../cocos2d/cocos/./base/ccRandom.h:117: error: undefined reference to 'rand' xxx/Pickle/proj.android/../cocos2d/cocos/./base/ccRandom.h:117: error: undefined reference to 'rand' xxx/proj.android/../cocos2d/cocos/./2d/CCActionTiledGrid.cpp:280: error: undefined reference to 'srand' xxx/proj.android/../cocos2d/cocos/./2d/CCActionTiledGrid.cpp:605: error: undefined reference to 'srand'
有两种表现,有可能是编译.so文件通过,但是在老设备上运行就crash,或者还有就是编译.so文件时直接提示上面的错误信息,无论哪种解决方法都一样,请设置APP_PLATFORM := android-19(或者更早的),因为google从android-21开始将以上那几个函数放到l.cpp文件里面去了,而之前是放在.h文件中的,而ndk和其他sdk不一样,它是向前兼容(Forwards Compatibility)的,也就是老版本兼容新版本,但新版本不兼容老版本,我们在使用jdk或者android sdk编译时总是喜欢用最新的版本编译,但是ndk编译时请使用老版本编译,其实最理想的状态是ndk的APP_PLATFORM应该等于manifest中的minSdkVersion的值,之前我一直使用android-23编译,才导致了这个问题;
stackoverflow上有人这么解释:
引用
Google have moved some of the C standard library functions like atof() from being inline functions in header files to normal functions. The latest NDKs will default to building a .so that is only compatible with the latest Android devices that have the atof() function in the device's standard C library (libc.so). This means if you run a library on an older device that has an older version of the C library, you will get an error loading the dll as the expected atof() function will not exist.
如果还是不行,可能你需要将上面那些报错的文件都检查一遍,如果哪个文件没有包含头文件#include <stdlib.h>,请自行添加(我是添加过的)。
好了,这个问题应该解决了,在armeabi和armeabi-v7a下面正常编译除了.so,并且老设备也正常运行,可是当我编译x86时,失败了,这就是下面要说的第2个问题。
2.在x86平台下编译so文件失败,提示信息如下
android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_vector.h:93:14: internal compiler error: in tree_node_structure_for_code, at tree.c:408
首先要说明一下我的开发和编译环境:MacOS X + clang,并且使用了c++11的一些新特性,比如lambda表达式,只要程序运行到lambda表达式就crash,最后查出来需要将APP_STL改为c++_static就可以了,既能编译x86架构又不会crash:
#Some functions in stdlib.h (atof, srand, etc) used to be static inlined functions #before android-21 and start to exist in libc.so from android-21. So to support #old devices before Android-21, APP_PLATFORM should be set before android-21, #otherwise, application will crash on old devices APP_PLATFORM := android-19 # ===================== Which APP_STL to use START==================================== #about C++ Library Support, see https://developer.android.com/ndk/guides/cpp-support.html#cs #Why use c++_static, see http://discuss.cocos2d-x.org/t/why-gnustl-static/23780 #(1)GNU STL runtime: This runtime is the GNU Standard C++ Library, (libstdc++-v3). #Its shared library file is named libgnustl_shared.so. #(2)libc++ runtime: This runtime is an Android port of LLVM libc++. Its shared library file is named libc++_shared.so. #And our dev environment is MacOS X with clang version:Apple LLVM version 7.3.0 (clang-703.0.31) #And about LLVM libc++, see http://libcxx.llvm.org/, which says: #libc++ is a 100% complete C++11 implementation on Apple's OS X. #LLVM and Clang can self host in C++ and C++11 mode with libc++ on Linux. #libc++ is also a 100% complete C++14 implementation. A list of new features and changes for C++14 can be found here. # ===================== Which APP_STL to use END==================================== # Instruct to use the static GNU STL implementation #APP_STL := gnustl_static APP_STL := c++_static #Enable C++11. However, pthread, rtti and exceptions aren’t enabled APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char APP_LDFLAGS := -latomic #Define this variable as 4.9 to select that version of the GCC compiler.Define this variable as clang to select the Clang compiler, which is the default value for NDK r13 and later. #see more:https://developer.android.com/ndk/guides/application_mk.html #NDK_TOOLCHAIN_VERSION := clang #Use the following command to compile: #cocos run -p android -m release --ap android-19 APP_ABI := armeabi, armeabi-v7a, x86, arm64-v8a ifeq ($(NDK_DEBUG),1) APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 APP_OPTIM := debug else APP_CPPFLAGS += -DNDEBUG APP_OPTIM := release endif
发表评论
-
Android项目集成Jenkins(JUnit test & Coverage)
2016-08-26 14:12 4362为了实现持续集成,提 ... -
Android短信监听功能(解决onChange触发两次的问题)
2016-06-16 18:51 6849前言 项目要做短信验证码自动填充的功能,基本上两种方法:Con ... -
Android实现可自动关闭的定时器
2015-12-03 18:54 1401之前一篇文章里有用到过一个封装好的定时器工具类,现在又做了一些 ... -
Android不太能够分辨率launcher icon的适配
2015-04-24 11:01 1908网上讲android适配不同分辨率的文章很多,但是很少有说明不 ... -
Android 根据屏幕尺寸适配控件尺寸(按比例缩放)
2015-04-03 18:28 4633在做facebook登录时,正好看到其SDK中一段代码,可以根 ... -
Android获取状态栏高度
2015-01-28 12:04 1192获取状态栏高度有两种方法: 1.如果是在Activity中: ... -
Apktool打包和解包
2014-12-02 17:49 0本文的学习内容参考自[Android实例] 【eoeAndro ... -
Android 控件自动“移入、暂停、移出”效果的实现
2014-09-05 09:54 2387一个常见的效果:控件自动移入屏幕,停留几秒,再移出屏幕。项目中 ... -
Google Map 如何捕获onTouchEvent
2014-09-02 17:42 1713当我的项目中需要捕获google map的touch事件时,才 ... -
Android日期时间选择器实现以及自定义大小
2014-08-27 20:01 62556本文主要讲两个内容:1.如何将DatePicker和TimeP ... -
ViewPager刷新单个页面的方法
2014-08-22 11:09 39083使用ViewPager做滑动切换图片的效果时,如果图片是从 ... -
Android使用MediaPlayer开发时抛IllegalStateException
2014-08-18 16:45 59792在我开发的语音播放程序中,首次播放语音没问题,第二次播放时 ... -
Android 含有图片和文字的Button的实现
2014-07-17 20:15 8853要实现一个同时包含图片和文字的按钮,粗糙一点的做法当然是直 ... -
LinearLayout半透明效果
2014-07-16 18:12 17430透明效果有很多中实现方式,可以代码实现,也可以直接在布局文件中 ... -
Android图片压缩(质量压缩和尺寸压缩)
2014-07-04 18:16 4218在网上调查了图片压缩的方法并实装后,大致上可以认为有两类压缩: ... -
Google Map无法显示:Error contacting Google servers. XXX authentication issue
2014-06-30 20:32 2080在开发google map时遇到的问题: 06-26 14 ... -
【转载】Android异步处理
2013-06-20 12:12 883关于Android异步处理的一整个系列的博文,共有4篇,博主写 ... -
android 写log到文件
2013-06-14 17:31 14210网上找的一个很强大的实现方法,原网页的链接找不到了,没法转载, ... -
android service被系统回收的解决方法
2013-06-14 11:20 7215自己的app的service总是容 ... -
Android 中的 Service 全面总结
2013-06-13 16:42 889关于Android Service的知识,可以参考以下博文,内 ...
相关推荐
手游开发引擎 Cocos2DX.手机游戏开发
手把手教你如何在Android平台下cocos2dx开发环境的搭建。
此代码在cocos2dx2.1.4下面编译有部分错误,我修改后,正常。 下下来后,请在VC++包含目录中链接(F:\cocos2d-x-2.1.4\cocos2dx\platform\win32;F:\cocos2d-x-2.1.4\cocos2dx\platform\third_party\win32\OGLES\GL\;...
cocos2dx-3.x游戏开发之旅电子版供大家下载参考。。。。。。
IOS开发中因为引入cocos2dx,导致代码审核不通过无法提交( Apple will stop accepting submissions of apps that use UIWebView APIs )。该问题的解决方案有两种:1)升级Cocos2dx的版本,在查看Cocoas官网及Cocoas...
基于cocos2dx3.2的ScrollView改良版,...由于cocos库太大,压缩包里已经移除cocos核心库,需要自行下载安装cocos2dx 3.2版本,并任意生成一个cocos2dx项目,把里面的cocos文件夹复制到ScrollViewDemo文件夹下即可。
这是用cocos2dx写的游戏,功能齐全,希望喜欢!
cocos2dx scrollview优化
cocos2dx 游戏开发系列之三 的 android工程源码
cocos2dx 模糊效果代码提供,尽情下载吧!
cocos2dx中使用精灵的例子,新手可参考。
《Cocos2dx高级开发教程制作自己的《捕鱼达人》》
cocos2dx 前端 游戏 高级开发 cocos2dx 前端 游戏 高级开发
Cocos2dx开发游戏框架搭建.pdf
cocos2dx_3d开发的飞机大战,包括源码和资源,mac xcode整长运行!windows自己导入调试。包括player场景,loading场景,战斗场景,效果酷炫,还有多机型适配处理方案!非常有价值!适合自学和二次开发!
cocos2d-x案例开发大全-第2章-cocos2dx3.3实现;
其中配置包括了cocos2dx 2.0.4和cocos2dx2.1.3在lua中所有函数,类,类的成员变量和方法以及相关枚举定义 使用方法: 1.打开本目录下LuaKeywords.config,将里面内容复制到LuaStudio的自定义函数配置中 2.拷贝cocos...
将Cocos2dx从win32移植到android平台 不用cygwin 只要简单的几步就可轻松搞定
COCOS2DX开发工具大全,免得开发者到处找,全部可以用,包括破解文件,具体包括: TexturePacker,CocosBuilder,cocos2dx粒子编辑器等
我所理解的cocos2dx pdf