I'm getting an error on Galaxy S6 Edge+ where it says it can't load native library. I'm using CSipSimple. It compiles fine if i don't include the arm64-v8a in the Application.mk file. I'm gettings this error:
[arm64-v8a] StaticLibrary : libpj_amr_stagefright_codec.a
[arm64-v8a] StaticLibrary : libpjsip.a
[arm64-v8a] Compile : pjmedia <= echo_webrtc_aec.c
In file included from jni/pjsip/android_toolchain/pjmedia/../../sources/pjmedia/../../../webrtc/sources/modules/audio_processing/aec/include/echo_cancellation.h:14:0,
from jni/pjsip/android_toolchain/pjmedia/../../sources/pjmedia/src/pjmedia/echo_webrtc_aec.c:57:
jni/pjsip/android_toolchain/pjmedia/../../sources/pjmedia/../../../webrtc/sources/typedefs.h:61:2: error: #error Please add support for your architecture in typedefs.h
#error Please add support for your architecture in typedefs.h
^
make[1]: *** [obj/local/arm64-v8a/objs/pjmedia/src/pjmedia/echo_webrtc_aec.o] Error 1
make[1]: *** Waiting for unfinished jobs....
rm jni/swig-glue/android_toolchain/../.pjsua.i
make[1]: Leaving directory `/home/user/data/svn/CSipSimple-trunk/CSipSimple'
make: *** [libraries] Error 2
Here's the portion of the make file (I'll include it in case messed it up):
JNI_DIR := $(call my-dir)
APP_OPTIM := release APP_ABI := armeabi armeabi-v7a x86 mips arm64-v8a
MY_USE_CSIPSIMPLE := 1
MY_USE_G729 := 1
I'm using the Android NDK r10e-rc4, if that helps.
Edit 1:
I also tried building using the following commands in order:
svn update, make clean, make udpate, make
I have the same problem. It looks like the code from WebRTC didn't support arm64-v8a yet.
Apply the patch below to 'webrtc/sources/typedefs.h' from your error message can fix this build break.
#define WEBRTC_ARCH_32_BITS
#define WEBRTC_ARCH_LITTLE_ENDIAN
#define WEBRTC_LITTLE_ENDIAN
+#elif defined(__aarch64__)
+#define WEBRTC_ARCH_64_BITS
+#define WEBRTC_ARCH_LITTLE_ENDIAN
+#define WEBRTC_LITTLE_ENDIAN
#elif defined(__MIPSEL__)
#define WEBRTC_ARCH_32_BITS
#define WEBRTC_ARCH_LITTLE_ENDIAN
also see: https://android.googlesource.com/platform/external/webrtc/+/android-6.0.1_r41/src/typedefs.h
note, the code from the link above doesn't contain #define WEBRTC_LITTLE_ENDIAN, but in the version of my code, WEBRTC_LITTLE_ENDIAN and WEBRTC_ARCH_LITTLE_ENDIAN come in pairs. so I think it depends on version.
Related
I am currently working on trying to compile the stressapptest (link: https://github.com/stressapptest/stressapptest) using the NDK environment, and for some reason, I'm having a hard time. These are the steps that I have taken:
Clone the repository onto my computer
Added a jni folder and moved all the files into it
Created an Application.mk file
Opened PowerShell from the location of my jni folder and execute ndk-build. This is the error I'm getting:
PS C:\Users\...\Desktop\stressapptest-master\stressapptest-master> ndk-build
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-16.
[arm64-v8a] Compile++ : stressapptest <= main.cc
In file included from jni/src/main.cc:17:
jni/src/sattypes.h:25:10: fatal error: 'algorithm' file not found
#include <algorithm>
^~~~~~~~~~~
1 error generated.
make: *** [obj/local/arm64-v8a/objs/stressapptest/src/main.o] Error 1
Is there anything else that I need in order to compile this to run on an Android system?
Set APP_STL to c++_shared in your Application.mk. ndk-build does not use any STL by default.
i am very new to the android ndk and opencv
but i have already run some samples/tutorials of opencv projects in Eclipse
therefore the opencv library should not be a problem
Here i want to run this camera project from github, i think it should work
After I downloaded it and import it into the Eclipse,
I encountered a problem :
When I run it it stops and finishes because the library cannot be loaded in the CameraActivity.
-> System.loadLibrary("PanoHDR");
I have tried to search the web for solutions but they either didn't work or I didn't understand them.
Do I need to do something like "ndk-build" at somewhere to make it work?
Could someone please help me? I cannot find any solution.
here is the default android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Tegra optimized OpenCV.mk
include /Users/milmil/Documents/NVPACK/OpenCV-2.4.5-Tegra-sdk-r2/sdk/native/jni/OpenCV-tegra3.mk
# Linker
LOCAL_LDLIBS += -llog
# Our module sources
LOCAL_MODULE := PanoHDR
LOCAL_SRC_FILES := PanoHDR.cpp Panorama.cpp HDR.cpp NativeLogging.cpp
include $(BUILD_SHARED_LIBRARY)
when i try to use ndk-build in cmd in the main dir of the project
it fails
jni/Android.mk:6: /sdk/native/jni/OpenCV.mk: No such file or directory
make: *** No rule to make target `/sdk/native/jni/OpenCV-tegra3'. Stop.
and it should be caused by this line in the Andriod.mk
include /Users/milmil/Documents/NVPACK/OpenCV-2.4.5-Tegra-sdk-r2/sdk/native/jni/OpenCV-tegra3.mk
I try to use the path of my opencv sdk
include /Android/OpenCV-3.1.0-android-sdk/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk
and it returns this in the cmd
Android NDK: WARNING:jni/Android.mk:PanoHDR: non-system libraries in linker flag
s: -lopencv_java3
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_S
TATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependenc
ies of the
Android NDK: current module
[armeabi-v7a] "Compile++ thumb": "PanoHDR <= PanoHDR.cpp"
The system cannot find the path specified.
make: *** [obj/local/armeabi-v7a/objs/PanoHDR/PanoHDR.o] Error 1
Thank you
=========================================================================
WARNING:jni/Android.mk:PanoHDR: non-system libraries in linker flag
s: -lopencv_java3
the above problem is solved by adding "OPENCV_LIB_TYPE=STATIC" in the android.mk, but still has this error "
[armeabi-v7a] "Compile++ thumb": "PanoHDR <= PanoHDR.cpp"
The system cannot find the path specified.
make: *** [obj/local/armeabi-v7a/objs/PanoHDR/PanoHDR.o] Error 1"
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 think I spent most of yesterday unsuccessfully wrestling with this, any help would greatly appreciated and make me extremely happy! Even a next step to try to find the root of the issue is something I'm stuck on at the moment!
I have an Android 2.2 project that's trying to reference a prebuilt LuaJIT static library but ndk-build gives me this error:
test_android.cpp:25: undefined reference to `luaL_newstate'
I built LuaJIT as liblua.a, I've placed that in the root of my JNI directory with the relevant headers. I've have one Android.mk as shown below:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := lua
LOCAL_SRC_FILES := liblua.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_CFLAGS := -Werror
LOCAL_SRC_FILES := test_android.cpp
LOCAL_LDLIBS := -llog -lGLESv2
LOCAL_STATIC_LIBRARIES := lua
include $(BUILD_SHARED_LIBRARY)
In test_andrdoid.cpp I've got this code:
extern "C"
{
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
}
void test()
{
lua_State* lua = lua_open();
}
This seems like a linker error, for some reason the static library file is not being correctly referenced. But, to me, the makefile seems correct.
Any help would be greatly appreciated!
To start with: is there anyway to see how everything is being linked
together and if my shared library module is really get access
to the static library?
Additional Information
Here's extra information that I think could be relevant!
Building the library
Maybe it's the static lib file that's not correct? (Is there anywhere I could download a prebuilt one to check?). I made it with this script (from the LuaJIT website). I'm using the latest stable LuaJIT, 1.1.8
NDK=/cygdrive/c/android-ndk-r8b
NDKABI=8
NDKVER=$NDK/toolchains/arm-linux-androideabi-4.4.3
NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
make linux HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
This builds fine and creates a liblua.a in the /src/ directory. (I ran nm on it and it lists out all the function prototypes I'd expect). I don't know if there's anything else I can do to ensure it's really a build for ARM?
NDKABI=8 means I'm targeting Android 2.2
Setting up the test Android Project
I create a brand new 2.2 android project using this command:
android create project --target 3 --name test --path . --activity TestActivity --package com.test
Target 3 maps to Android 2.2 on my system (using android list devices).
I create the jni folder and have a test_android.h and test_android.cpp. Then I use ndk-build to build them - which works fine when I'm not trying to reference LuaJIT. When I do try and use Lua I get the following error:
Full Error Message
Cygwin : Generating dependency file converter script
Compile++ thumb : test <= test_android.cpp
In file included from jni/test_android.h:3:0, from jni/test_android.cpp:2:
C:/android-ndk-r8b/platforms/android-8/arch-arm/usr/include/jni.h:592:13: note:
the mangling of 'va_list' has changed in GCC 4.4
Prebuilt : liblua.a <= jni/
StaticLibrary : libstdc++.a
SharedLibrary : libtest.so
obj/local/armeabi/objs/test/test_android.o: In function `test()':
C:\Users\Grrr\Documents\mycode\static_lib_test/jni/test_android.cpp:25: undefined reference to `luaL_newstate'
collect2: ld returned 1 exit status
/cygdrive/c/android-ndk-r8b/build/core/build-binary.mk:378: recipe for target `obj/local/armeabi/libtest.so' failed make: *** [obj/local/armeabi/libtest.so] Error 1
Most of the issues I've seen searching around are due to the local library include order, as I only have one library this shouldn't be an issue and suggests I've managed to get something more fundamental wrong :)
Update
I've since built normal Lua and added that as prebuilt static library and it works fine. I suspect its how I've built LuaJIT but I'm not sure how to correctly build it, or find a working prebuilt version.
The linking for this was fine, or at least the makefile was.
The problem was the LuaJIT library wasn't built for ARM (I used objdump -a lualib.a, to check this). I downloaded the latest LuaJIT, ran the script under linux and got an ARM library. Everything links nicely now!
I am using open-ssl source given at https://github.com/eighthave/openssl-android
to build a library which can be used in android project.
As per instructions given at README.txt, I am able to compile it for the the Android platform version 2.2 (level -8)
But my app requires it to be 2.1 (level -7) compatible.
I tried following options with the default.properties file ( https://github.com/eighthave/openssl-android/blob/master/default.properties )
1) set target=android-7
2) set target=android-5
But when I compile it using command ndk-build, it gives following error
Compile thumb : crypto <= dsa_vrf.c
Compile thumb : crypto <= dso_dl.c
Compile thumb : crypto <= dso_dlfcn.c
/Crypto/openssl-android/crypto/dso/dso_dlfcn.c: In function 'dlfcn_pathbyaddr':
/Crypto/openssl-android/crypto/dso/dso_dlfcn.c:445: error: 'Dl_info' undeclared (first use in this function)
/Crypto/openssl-android/crypto/dso/dso_dlfcn.c:445: error: (Each undeclared identifier is reported only once
/Crypto/openssl-android/crypto/dso/dso_dlfcn.c:445: error: for each function it appears in.)
/Crypto/openssl-android/crypto/dso/dso_dlfcn.c:445: error: expected ';' before 'dli'
/Crypto/openssl-android/crypto/dso/dso_dlfcn.c:455: error: 'dli' undeclared (first use in this function)
make: *** [obj/local/armeabi/objs/crypto/dso/dso_dlfcn.o] Error 1
As per error message- Dl_info is not defined. but if we go to file dso_dlfcn.c , the definition for the structure is already provided. (https://github.com/eighthave/openssl-android/blob/master/crypto/dso/dso_dlfcn.c)
And this code compiled for target=android-8 in default properties file, but not for android-7 or android-5.
Request you to help me to resolve this error. and let me know what all changes needs to be done in order to compile it for android 2.1 platform.
Thanks in advance.
Try to include the following piece of code into dso_dlfcn.c:
typedef struct {
const char *dli_fname; /* Pathname of shared object that
contains address */
void *dli_fbase; /* Address at which shared object
is loaded */
const char *dli_sname; /* Name of nearest symbol with address
lower than addr */
void *dli_saddr; /* Exact address of symbol named
in dli_sname */
} Dl_info;
int dladdr(const void *addr, Dl_info *info) { return 0; }
Before:
#ifdef __linux
# ifndef _GNU_SOURCE
# define _GNU_SOURCE /* make sure dladdr is declared */
# endif
#endif
After that in my case the library is built.
Try to install with latest NDK version and update Application.mk file appropriately.
LOCAL_PATH := $(call my-dir)
APP_PLATFORM := android-19
NDK_TOOLCHAIN_VERSION := clang
APP_ABI := armeabi-v7a
APP_STL := gnustl_static
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -DANDROID
APP_PROJECT_PATH := $(shell pwd)
APP_BUILD_SCRIPT := $(LOCAL_PATH)/../Android.mk
The above 2 problems will be solved.
I had one issue with #Yuri's solution and had to improve it alittle. My APP_ABI is set to all in Application.mk. In my case it meant that among armeabi and armeabi-v7a I'm building also for x86 and mips. I have also android-9 target installed in android sdk to use in other projects. x86 and mips are supported by ndk starting from android-9. As written in the docs, when ndk-build will start building these targets, it will switch to android-9 target automatically. And what? - Yes, it will fail to compile :-). Here is my solution:
In crypto/Android.mk find the line local_c_flags :=
-DNO_WINDOWS_BRAINDEATH. After the line write this http://pastebin.com/7euUVD7A.
Yuri's code has to be inserted into if defined: http://pastebin.com/V58gTSBU
By the way, I've inserted Yuri's block after #include <openssl/dso.h> but not before #ifdef __linux