Assembler Messages: Branch out of range - android

I'm developing game on cocos2d-x with C++.
I developed whole code in xCode. compiled, run in iphone and ipad, run as expected.
But when compiling code for android in windows 7 OS, using Cygwin (64-bit)..I encounterd following code..
$ ./build_native.sh
NDK_ROOT = D:\android-ndk-r9
COCOS2DX_ROOT = /cygdrive/d/cocos2d-x-2.2/projects/Totals/proj.android/../../..
APP_ROOT = /cygdrive/d/cocos2d-x-2.2/projects/Totals/proj.android/..
APP_ANDROID_ROOT = /cygdrive/d/cocos2d-x-2.2/projects/Totals/proj.android
Using prebuilt externals
make: Entering directory '/cygdrive/d/cocos2d-x-2.2/projects/Totals/proj.android'
Android NDK: WARNING:/cygdrive/d/cocos2d-x-2.2/projects/Totals/proj.android/../../../cocos2dx/Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries
Compile++ thumb : cocos2dcpp_shared <= AppDelegate.cpp
Compile++ thumb : cocos2dcpp_shared <= PlayerSelection.cpp
jni/../../Classes/PlayerSelection.cpp: In member function 'void PlayerSelection::update()':
jni/../../Classes/PlayerSelection.cpp:1511:17: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
Compile++ thumb : cocos2dcpp_shared <= GameScene.cpp
C:\cygwin64\tmp\ccdF8Sjo.s: Assembler messages:
C:\cygwin64\tmp\ccdF8Sjo.s:12180: Error: branch out of range
/cygdrive/d/android-ndk-r9/build/core/build-binary.mk:348: recipe for target 'obj/local/armeabi/objs/cocos2dcpp_shared/__/__/Classes/GameScene.o' failed
make: *** [obj/local/armeabi/objs/cocos2dcpp_shared/__/__/Classes/GameScene.o] Error 1
make: Leaving directory '/cygdrive/d/cocos2d-x-2.2/projects/Totals/proj.android'
In the Above command-line output the problem is:
Compile++ thumb : cocos2dcpp_shared <= GameScene.cpp
C:\cygwin64\tmp\ccdF8Sjo.s: Assembler messages:
C:\cygwin64\tmp\ccdF8Sjo.s:12180: Error: branch out of range
I tried Following links:
Why does branching occur in assembly code while comparing for a number to be in range?
https://in.answers.yahoo.com/question/index?qid=20100603163224AAAGX7J
branch out of range compile error
None of above references were helpfull that I could compile code.

After battling with my code by checking each function ONE by ONE, I found the problem was lying in nested switch case, if anyone happen to hit this problem this could be it..
And thank you LearnCocos2D for Your interest.

Related

Undefined reference to 'jniRegisterNativeMethods' Android NDK

I'm trying to build the .so file from available NDK project. But I encounter the
undefined reference to 'jniRegisterNativeMethods' error when I try to compile the code using cmd with ndk-build
Here I'm posting the block of that execution
Android NDK: WARNING:jni/Android.mk:gba: non-system libraries in linker flags: -lnativehelper
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
[armeabi] Compile++ arm : gba <= emulator.cpp
[armeabi] SharedLibrary : libgba.so
C:/sdk/android-ndk-r10e-windows-x86_64/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lnativehelper
jni/gbalib/nativehelper/JNIHelp.h:108: error: undefined reference to 'jniRegisterNativeMethods'
collect2.exe: error: ld returned 1 exit status
make.exe: *** [obj/local/armeabi/libgba.so] Error 1
E:\Android-Projects-Archieve\Library-Archives\gameboid>
I expect it to build an .so file called libgba.so Let me know in the comments if you need more info to look into this issue. Thanks in advance.

Build command failed on telegram

I got this error on the last version of the telegram.
telegram source code version: 4.9.0
envirement :
ubuntu 17.10.0
android studio:3.2 canary 9
ndk version: 14.1.3816874
[armeabi-v7a] Compile++ arm : tmessages.28 <= TgNetWrapper.cpp
/home/joker/telegram490/TMessagesProj/jni/./jni.c: In function
'listdir':
/home/joker/telegram490/TMessagesProj/jni/./jni.c:193:31: error:
'struct stat' has no member named 'st_atim'
if (attrib.st_atim.tv_sec != 0) {
^
/home/joker/telegram490/TMessagesProj/jni/./jni.c:194:35: error:
'struct stat' has no member named 'st_atim'
if (attrib.st_atim.tv_sec < time) {
^
/home/joker/telegram490/TMessagesProj/jni/./jni.c:198:35: error:
'struct stat' has no member named 'st_mtim'
if (attrib.st_mtim.tv_sec < time) {
^make: ***
[/home/joker/telegram490/TMessagesProj/build/intermediates
/ndkBuild/afat/
debug/obj/local/armeabi-v7a/objs-debug/tmessages.28/./jni.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from
/home/joker/telegram490/TMessagesProj/jni/./tgnet/TLObject.h:13:0,
from
/home/joker/telegram490/TMessagesProj/jni/./tgnet/ApiScheme.h:15,
from
/home/joker/telegram490/TMessagesProj/jni/./TgNetWrapper.cpp:2:
/home/joker/telegram490/TMessagesProj/jni/./tgnet/Defines.h: In
function 'std::string to_string_uint64(uint64_t)':
/home/joker/telegram490/TMessagesProj/jni/./tgnet/Defines.h:184:32:
error: expected ')' before 'PRIu64'
int len = sprintf(buf, "%" PRIu64, value);
Edit:
thanks to #anubhav-gupta, Through SDK Manager, I can only upgrade to version r18-beta1.
after the upgrade I face up with this error:
Android NDK: APP_STL gnustl_static is no longer supported. Please switch to either c++_static or c++_shared
Edit:
update NDK to r15 and The problem was solved.
The main problem is in this line 'struct stat' has no member named 'st_atim'
If you're using a modern version of the NDK, you'll have a modern struct stat: https://android.googlesource.com/platform/bionic/+/master/libc/include/sys/stat.h
Note that you need to be using the NDK's unified headers to get the up to date headers. This is the default in r15, but opt-in for r14.

error when updated libpng for cocos2d-x

i have problem when replace fixed libpng. i used cocos2d1.0.1-x-0.13.0-beta/ndkr8
Compile++ thumb : cocos2dx_static <= CCFileUtils.cpp
Compile++ thumb : cocos2dx_static <= CCGL.cpp
Compile++ thumb : cocos2dx_static <= CCImage.cpp
C:/Users/trach/Pictures/cocos2d-1.0.1-x-0.13.0-beta/cocos2dx/platform/CCImage.cpp: In member function 'bool cocos2d::CCImage::_initWithPngData(void, int)':
C:/Users/trach/Pictures/cocos2d-1.0.1-x-0.13.0-beta/cocos2dx/platform/CCImage.cpp:257:33: error: invalid use of incomplete type 'png_info {aka struct png_info_def}'
C:/Users/trach/Pictures/cocos2d-1.0.1-x-0.13.0-beta/cocos2dx/platform/third_party/android/prebuilt/libpng/include/png.h:594:16: error: forward declaration of 'png_info {aka struct png_info_def}'
make: ** [/cygdrive/c/Users/trach/Pictures/android-ndk-r8e/build/core/build-binary.mk:273: obj/local/armeabi/objs/cocos2dx_static/platform/CCImage.o] Error 1
make: Leaving directory '/cygdrive/c/Users/trach/Pictures/cocos2d-1.0.1-x-0.13.0-beta/show_entry'
cp: cannot create regular file '/cygdrive/c/Users/trach/Pictures/cocos2d-1.0.1-x-0.13.0-beta/show_entry/jni/../libs/armeabi': No such file or directory
libpng-1.5 and later do not allow direct access to the members of png_ptr, so you have to replace things like
png_info->width
png_ptr->width
with things like
png_get_image_width(png_ptr,png_info)
in your application, or downgrade libpng to the latest 1.2.x version.

no archive symbol table (run ranlib) while building libcryptopp.a through ndk-build

Here i am trying to build libcryptopp.a through ndk-build but i getting error as shown below.
Android.mk
Application.mk
setenv-android.sh its while creating libcryptopp.a and .so by using cryptopp 5.6.3
Error produced in terminal as below
$ /Users/kasbahapple/Documents/AndroidDocs/AndroidADT/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/ndk-build
[armeabi] Gdbserver : [arm-linux-androideabi-4.8] libs/armeabi/gdbserver
[armeabi] Gdbsetup : libs/armeabi/gdb.setup
[armeabi-v7a] Gdbserver : [arm-linux-androideabi-4.8] libs/armeabi-v7a/gdbserver
[armeabi-v7a] Gdbsetup : libs/armeabi-v7a/gdb.setup
[x86] Gdbserver : [x86-4.8] libs/x86/gdbserver
[x86] Gdbsetup : libs/x86/gdb.setup
[armeabi] Executable : source_file
/Users/kasbahapple/Documents/AndroidDocs/AndroidADT/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: jni/nativelib/libcryptopp.a: no archive symbol table (run ranlib)
/Users/kasbahapple/Documents/AndroidDocs/AndroidADT/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/platforms/android-8/arch-arm/usr/lib/crtbegin_dynamic.o:crtbrand.c:function _start: error: undefined reference to 'main'
collect2: error: ld returned 1 exit status
I really struggling to build c++ static library through NDK.
I looking for solution. Give me a complete steps if i doing wrong.
no archive symbol table (run ranlib) while building libcryptopp.a through ndk-build
After you build the Crypto++ library through Android.mk, you need to run ranlib on libcryptopp.a. Unfortunately, I don't know how to tell Android.mk to run ranlib.
I'm guessing - and its purely a guess - that you have to do this in two steps in Android.mk. You cannot cut to the chase and build the shared object directly from sources.
build libcryptopp.a, running ranlib
build libcryptopp.so from libcryptopp.a
setenv-android.sh its while creating libcryptopp.a and .so by using cryptopp 5.6.3
...
APP_STL = gnustl_static
The script setenv-android.sh uses STLport because of GNU licensing encumbrances. Your Android.mk uses GNU's STL.
You should probably also use the same C++ runtime libraries. Additionally, all libraries must use the same runtime. That means OpenGL, Crypto++, [Favorite library], must use the same C++ runtime, and there's no mixing and matching. In addition, because multiple libraries are using the C++ runtime, you must use the shared object, and not the static version.
There's a README in the NDK somewhere that discusses it. I think its called CPP-README or similar.
Also, when you invoke the setenv-android.sh, you must include a leading dot. Then you run the GNUmakefile-cross:
. ./setenv-android.sh
make -f GNUmakefile-cross static dynamic cryptest.exe
Finally, please don't post pictures. I can barely read them because my eyes are old. Usually, appeasing one user does not matter. In this case, I'm the guy who wrote the scripts and the wiki pages, so you want to make it easy on me, and not hard on me :)

Cocos2d-x fails to compile C++ code in MacOs using ./build_native.sh

I'm using android-ndk-r9b and cocos2d-x-2.1.4 under MacOs Mavericks. I was able to create the android application for cocos2d-x, but when I tried to compile the C++ code using ./build_native.sh script, the compiler get me some warnings and at the end failed.
These warnings are:
Android NDK: WARNING: APP_PLATFORM android-18 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml
Android NDK: WARNING:/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries
[armeabi] Compile thumb : cocos2dx_static <= quaternion.c
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/kazmath/src/quaternion.c: In function 'kmQuaternionAssign':
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/kazmath/src/quaternion.c:478:5: warning: incompatible implicit declaration of built-in function 'memcpy' [enabled by default]
[armeabi] Compile thumb : cocos2dx_static <= vec4.c
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/kazmath/src/vec4.c: In function 'kmVec4Assign':
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/kazmath/src/vec4.c:150:5: warning: incompatible implicit declaration of built-in function 'memcpy' [enabled by default]
[armeabi] Compile++ thumb: cocos2dx_static <= CCCommon.cpp
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/platform/android/CCCommon.cpp: In function 'void cocos2d::CCLog(char const*, ...)':
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/platform/android/CCCommon.cpp:44:72: error: format not a string literal and no format arguments [-Werror=format-security]
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/platform/android/CCCommon.cpp: In function 'void cocos2d::CCLuaLog(char const*)':
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/platform/android/CCCommon.cpp:54:77: error: format not a string literal and no format arguments [-Werror=format-security]
cc1plus: some warnings being treated as errors
I'm wondering if someone has encounter similar errors, how how to revolve it?
Thanks!
Same problem here (Cocos2DX 2.1.1)
http://www.cocos2d-x.org/forums/6/topics/32437?r=39742#message-39742
You can shut down the compiler error:
in Application.mk:
APP_CFLAGS += -Wno-error=format-security
or better, solve the problem of string format, in 4 points of cocos code (as you can see in the link above):
1 - CCCommon.cpp - __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf); -> __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf);
2 - SimpleAudioEngine.cpp - LOGD(deviceModel); -> LOGD("%s",deviceModel);
3 - OpenSLEngine.cpp - LOGD(errorInfo); -> LOGD("%s",errorInfo);
4 - SimpleAudioEngineOpenSL.cpp - LOGD(errorInfo); -> LOGD("%s",errorInfo);

Categories

Resources