用NDK r9版本编译cocos2d x 2.0.4遇到的各个坑
下面详细介绍一下用NDK r9版本编译cocos2d x 2.0.4可能会遇到的各个坑吧。 错误提示1: Android NDK: WARNING:E:\cocos2d-x\cocos2d-2.0-x-2.0.4/cocos2dx/Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries Gdbserver : [a
下面详细介绍一下用NDK r9版本编译cocos2d x 2.0.4可能会遇到的各个坑吧。
错误提示1:
Android NDK: WARNING:E:\cocos2d-x\cocos2d-2.0-x-2.0.4/cocos2dx/Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries
Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
"Compile++ thumb : cocosdenshion_static
E:\cocos2d-x\cocos2d-2.0-x-2.0.4/CocosDenshion/android/SimpleAudioEngine.cpp: In constructor 'CocosDenshion::SimpleAudioEngine::SimpleAudioEngine()':
E:\cocos2d-x\cocos2d-2.0-x-2.0.4/CocosDenshion/android/SimpleAudioEngine.cpp:159:2: error: format not a string literal and no format arguments [-Werror=format-security]
cc1plus.exe: some warnings being treated as errors
make: *** [obj/local/armeabi/objs-debug/cocosdenshion_static/SimpleAudioEngine.o] Error 1
解决方法:把SimpleAudioEngine.cpp第159行注释掉
在文件夹CocosDenshion/android中找到SimpleAudioEngine.cpp文件,定位到第159行,将其注释掉如下:
//LOGD(deviceModel);
再次用Cygwin Terminal软件运行build_native.sh,又出现新的提示错误。
错误提示2:
E:/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/testa/proj.android/../../CocosDenshion/android/opensl/OpenSLEngine.cpp:292:45: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
[enabled by default]
E:/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/testa/proj.android/../../CocosDenshion/android/opensl/OpenSLEngine.cpp:292:45: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
E:/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/testa/proj.android/../../CocosDenshion/android/opensl/OpenSLEngine.cpp: In member function 'void OpenSLEngine::create Engine(void*)':
E:/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/testa/proj.android/../../CocosDenshion/android/opensl/OpenSLEngine.cpp:324:3: error: format not a string literal and no format arguments [-Werror=format-security]
cc1plus.exe: some warnings being treated as errors
/cygdrive/e/android-ndk-r9c/build/core/build-binary.mk:388: recipe for target 'obj/local/armeabi/objs-debug/cocosdenshion_static/opensl/OpenSLEngine.o' failed
make: *** [obj/local/armeabi/objs-debug/cocosdenshion_static/opensl/OpenSLEngine.o] Error 1
make: Leaving directory '/cygdrive/e/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/testa/proj.android'
错误提示解读:warning我们就不管了,先只看error,OpenSLEngine.cpp文件324行error。
解决方法:把cocos2d-2.0-x-2.0.4\CocosDenshion\android\opensl文件夹下的OpenSLEngine.cpp文件
324行注释掉 /*LOGD(errorInfo);*/
再次运行build_native.sh,又提示错误。
错误提示3:
E:/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/testa/proj.android/../../CocosDenshion/android/opensl/OpenSLEngine.cpp:292:45: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
[enabled by default]
E:/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/testa/proj.android/../../CocosDenshion/android/opensl/OpenSLEngine.cpp:292:45: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
[armeabi] Compile++ thumb: cocosdenshion_static
E:/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/testa/proj.android/../../CocosDenshion/android/opensl/SimpleAudioEngineOpenSL.cpp: In member function 'bool SimpleAudioEngineOpenSL::initEngine()':
E:/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/testa/proj.android/../../CocosDenshion/android/opensl/SimpleAudioEngineOpenSL.cpp:41:5: error: format not a string literal and no format arguments [-Werror=format-security]
cc1plus.exe: some warnings being treated as errors
/cygdrive/e/android-ndk-r9c/build/core/build-binary.mk:388: recipe for target 'obj/local/armeabi/objs-debug/cocosdens hion_static/opensl/SimpleAudioEngineOpenSL.o' failed
make: *** [obj/local/armeabi/objs-debug/cocosdenshion_static/opensl/SimpleAudioEngineOpenSL.o] Error 1
make: Leaving directory '/cygdrive/e/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/testa/proj.android'
这次轮到SimpleAudioEngineOpenSL.cpp文件第41行。
解决方法:把cocos2d-2.0-x-2.0.4\CocosDenshion\android\opensl文件夹下的SimpleAudioEngineOpenSL.cpp文件第41行注释掉:
/* LOGD(errorInfo);*/
再次运行build_native.sh。又提示错误,warning我们就不管了,先只看error。
错误提示4:
/cygdrive/e/android-ndk-r9c/build/core/build-binary.mk:388: recipe for target 'obj/local/armeabi/objs-debug/cocos2d x_static/platform/android/CCCommon.o' failed
make: *** [obj/local/armeabi/objs-debug/cocos2dx_static/platform/android/CCCommon.o] Error 1
make: Leaving directory '/cygdrive/e/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/testa/proj.android'
解决方法:这次我们在Application.mk文件后面添加下面代码:
APP_CPPFLAGS += -Wno-error=format-security
再次运行build_native.sh,然后一切就顺利了!我把so文件(libgame.so)在eclipse里面导入android项目,并编译成apk文件,测试成功。
至此,NDK r9版本就可以用build_native.sh编译成so文件(libgame.so),
已经在真机上测试cocos2d x的hello World成功。
如果再有其他报错应该不是NDK r9本身的原因,建议考虑NDK_ROOT是否设置,或者权限的问题,
或者是项目的代码问题(有一些VC++允许通过的,这里会有细微的差异)。
如果第一次尝试做交叉编译的同学,建议不要用自己写的Classes代码编译,
可以考虑用官方的HelloWorld,这样可以减少困扰。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Numpy is an important mathematics library in Python. It provides efficient array operations and scientific calculation functions and is widely used in data analysis, machine learning, deep learning and other fields. When using numpy, we often need to check the version number of numpy to determine the functions supported by the current environment. This article will introduce how to quickly check the numpy version and provide specific code examples. Method 1: Use the __version__ attribute that comes with numpy. The numpy module comes with a __

Methods to check the maven version: 1. Use the command line; 2. Check the environment variables; 3. Use the IDE; 4. Check the pom.xml file. Detailed introduction: 1. Use the command line, enter "mvn -v" or "mvn --version" in the command line, and then press Enter. This will display the Maven version information and Java version information; 2. View the environment variables , on some systems, you can check the environment variables to find the Maven version information, enter the command on the command line, and then press Enter, etc.

To update the curl version under Linux, you can follow the steps below: Check the current curl version: First, you need to determine the curl version installed in the current system. Open a terminal and execute the following command: curl --version This command will display the current curl version information. Confirm available curl version: Before updating curl, you need to confirm the latest version available. You can visit curl's official website (curl.haxx.se) or related software sources to find the latest version of curl. Download the curl source code: Using curl or a browser, download the source code file for the curl version of your choice (usually .tar.gz or .tar.bz2

How to easily check the installed version of Oracle requires specific code examples. As a software widely used in enterprise-level database management systems, the Oracle database has many versions and different installation methods. In our daily work, we often need to check the installed version of the Oracle database for corresponding operations and maintenance. This article will introduce how to easily check the installed version of Oracle and give specific code examples. Method 1: Through SQL query in the Oracle database, we can

Checking the Kylin operating system version and kernel version In the Kirin operating system, knowing how to check the system version and kernel version is the basis for system management and maintenance. Method 1 to check the Kylin operating system version: Use the /etc/.kyinfo file. To check the Kylin operating system version, you can check the /etc/.kyinfo file. This file contains operating system version information. Execute the following command: cat/etc/.kyinfo This command will display detailed version information of the operating system. Method 2: Use the /etc/issue file Another way to check the operating system version is by looking at the /etc/issue file. This file also provides version information, but may not be as good as the .kyinfo file

Done in one minute: How to update the pip version, specific code examples are required. With the rapid development of Python, pip has become a standard tool for Python package management. However, as time goes by, pip versions are constantly updated. In order to be able to use the latest features and fix possible security vulnerabilities, it is very important to update the pip version. This article will explain how to quickly update pip in one minute and provide specific code examples. First, we need to open a command line window. In Windows systems, you can use

Regarding Llama3, new test results have been released - the large model evaluation community LMSYS released a large model ranking list. Llama3 ranked fifth, and tied for first place with GPT-4 in the English category. The picture is different from other benchmarks. This list is based on one-on-one battles between models, and the evaluators from all over the network make their own propositions and scores. In the end, Llama3 ranked fifth on the list, followed by three different versions of GPT-4 and Claude3 Super Cup Opus. In the English single list, Llama3 overtook Claude and tied with GPT-4. Regarding this result, Meta’s chief scientist LeCun was very happy and forwarded the tweet and

The DP interface is an important interface cable in the computer. When using the computer, many users want to know how to check whether the DP interface is 1.2 or 1.4. In fact, they only need to check it in GPU-Z. How to determine whether the dp interface is 1.2 or 1.4: 1. First, select "Advanced" in GPU-Z. 2. Look at "Monitor1" in "General" under "Advanced", you can see the two items "LinkRate (current)" and "Lanes (current)". 3. Finally, if 8.1Gbps×4 is displayed, it means DP1.3 version or above, usually DP1.4. If it is 5.4Gbps×4, then
