When I build my C/C++ library using ndk-build command from the command line, it works.
[armeabi] Prebuilt : libVidyoClientApp.so <= jni/lib/
[armeabi] Install : libVidyoClientApp.so => libs/armeabi/libVidyoClientApp.so
[armeabi] Compile thumb : vidyoguestapi <= NCR.JNI.VidyoExports.c
[armeabi] Compile++ thumb: vidyoguestapi <= Ncr.Jni.Wrapper.cpp
In file included from m:/src/projects/java/VideoPlatform/app/src/main/jni/Ncr.Jni.Wrapper.cpp:6:0:
m:/src/projects/java/VideoPlatform/app/src/main/jni/include/Ncr.Jni.Wrapper.h:13:1: warning: 'typedef' was ignored in th
is declaration [enabled by default]
};
^
[armeabi] Compile++ thumb: vidyoguestapi <= NCR.Vidyo.SDK.cpp
In file included from m:/src/projects/java/VideoPlatform/app/src/main/jni/NCR.Vidyo.SDK.cpp:7:0:
m:/src/projects/java/VideoPlatform/app/src/main/jni/include/NCR.Jni.Wrapper.h:13:1: warning: 'typedef' was ignored in th
is declaration [enabled by default]
};
^
[armeabi] StaticLibrary : libstdc++.a
[armeabi] SharedLibrary : libvidyoguestapi.so
[armeabi] Install : libvidyoguestapi.so => libs/armeabi/libvidyoguestapi.so
But when I try to build my project in Android studio I get a compiler error:
M:\src\projects\java\VideoPlatform\app\build\intermediates\ndk\debug\obj/local/arm64-v8a/objs/vidyoguestapi/M_\src\projects\java\VideoPlatform\app\src\main\jni\NCR.JNI.VidyoExports.o: In function `Java_com_ncr_mobilevideo_videosdk_VidyoGuestClient_sdkLoginGuest':
M:\src\projects\java\VideoPlatform\app\src\main\jni\NCR.JNI.VidyoExports.c
Error:(50) undefined reference to `VidyoClientInitialize'
collect2.exe: error: ld returned 1 exit status
make.exe: *** [M:\src\projects\java\VideoPlatform\app\build\intermediates\ndk\debug\obj/local/arm64-v8a/libvidyoguestapi.so] Error 1
What is different between commandline ndk-build and Android Studio?
FYI: I remove the line that references VidyoClientInitialize, everything builds in both the commandline and Android studio. So it seems like something environment, but I'm not sure what to look at
Right now, Android Studio creates a new Android.mk on-the-fly to compile your C/C++ sources, ignoring all your dependencies on other prebuilt libraries since he can't handle them.
A better NDK support from AS/gradle is supposed to be out really soon, but in the meantime you can deactivate it and let it integrate your native libs from libs/(armeabi,armeabi-v7a,x86,...) by setting this inside build.gradle:
android {
sourceSets.main {
jniLibs.srcDir 'src/main/libs' //set libs as .so's location instead of jniLibs
jni.srcDirs = [] //disable automatic ndk-build call with auto-generated Android.mk
}
}
Related
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.
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.
After downloading the Android Source Code using the repo command as suggested on the page:
repo init -u https://android.googlesource.com/platform/manifest
I was able to compile the whole project without issue using make.
What I would like to do is compile my own fork of android.media.MediaPlayer, but I am lost as to how to set up the build.
I tried using ndk-build in /frameworks/base/media/libmedia, and got the following output:
Android NDK: WARNING:/home/user/android/WORKING_DIRECTORY/frameworks/base/media/jni/Android.mk:media_jni: non-system libraries in linker flags: -lpthread
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++ thumb: audioeffect_jni <= android_media_AudioEffect.cpp
/home/user/android/WORKING_DIRECTORY/frameworks/base/media/jni/audioeffect/android_media_AudioEffect.cpp:22:23: fatal error: utils/Log.h: No such file or directory
compilation terminated.
make: *** [/home/user/android/WORKING_DIRECTORY/frameworks/base/media/obj/local/armeabi/objs/audioeffect_jni/android_media_AudioEffect.o] Error 1
How could I compile a .jar that contained libmedia and android.media.MediaPlayer so that I could simply drop it into a project and use that instead of the default android.media.MediaPlayer?
I have been following this tutorial http://developer.samsung.com/android/technical-docs/Porting-and-using-LAME-MP3-on-Android-with-JNI, however I dont seem to get it to compile when it comes to Compilation with NDK section. The following is the error that I get
Android NDK: WARNING: APP_PLATFORM android-17 is larger than android:minSdkVersion 7 in ./AndroidManifest.xml
[armeabi] Compile thumb : mp3lame <= bitstream.c
jni/./libmp3lame/bitstream.c:33:18: fatal error: lame.h: No such file or directory
compilation terminated.
make.exe: * [obj/local/armeabi/objs/mp3lame/./libmp3lame/bitstream.o] Error 1
I have added
LOCAL_C_INCLUDES += jni/include
to Android.mk, so it can find the ".h" needed.
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);