How to generate libpjsua2.so for x86 abi in jnilibs - android

I want to test the app with android 10 in emulator.So for that I only have "armeabi", "armeabi-v7a","arm64-v8a" in jnilibs. But running app with android 10 device(Emulator), requires x86 abi. So for that first I have downloaded ndk for x86.And the second thing is I want to generate libpjsua2.so for x86 abi.
I am using pjsip library.
I have referred to https://trac.pjsip.org/repos/wiki/Getting-Started/Android. What I have tried is,
1) Downloaded latest pjsip version and extracted in folder.
2) Followed the steps given in pjsip website as below,
$ cd /path/to/your/pjsip/dir
$ export ANDROID_NDK_ROOT=/path_to_android_ndk_dir
$ ./configure-android
$ make dep && make clean && make
$ cd /path/to/your/pjsip/dir
$ make clean
# cleanup pjsua sample app
$ cd pjsip-apps/src/pjsua/android/jni
$ make clean
# also cleanup pjsua2 sample app (SWIG)
$ cd /path/to/your/pjsip/dir
$ cd pjsip-apps/src/swig
$ make clean
$ cd pjsip-apps/src/swig
$ make clean
TARGET_ABI=x86 ./configure-android --use-ndk-cflags
Got error when reached above code,
LDFLAGS = --sysroot= -L/libs/x86/
LIBS = -lgnustl_static -lc -lgcc -ldl
AR = /home/Android/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
RANLIB = /home/Android/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
TARGET_HOST = llvm-linux-android
TARGET_ABI = x86
checking build system type... x86_64-unknown-linux-gnu
checking host system type... Invalid configuration `llvm-linux-android': machine `llvm' not recognized
aconfigure: error: /bin/sh ./config.sub llvm-linux-android failed
In my pjsip2.7 folder I found a folder named llvm but that is a empty folder. I doesn't know What is that. I am using cent os 7. Why I am getting this error? What do I need to do to overcome this.

Try compile with this builder
replace in ./config.cong you are using 2.10
# PJSIP Version to download
PJSIP_VERSION=2.10
./prepare-build-system
and then
./build

Related

Tensorflow android cmake build can't find python

I'm trying to build tflite in my android project using cmake. I've managed to work this approach on the linux (debian) version of the same project.When compiling the arm64 version I followed the official docs When I open android studio and press build/run on top right corner, I get this error:
In file included from /home/user/Desktop/official_stuff/tensorflow_src/tensorflow/lite/python/interpreter_wrapper/numpy.cc:17:
In file included from /home/user/Desktop/official_stuff/tensorflow_src/tensorflow/lite/python/interpreter_wrapper/numpy.h:49:
In file included from /usr/include/python3.9/Python.h:8:
/usr/include/python3.9/pyconfig.h:9:12: fatal error: 'aarch64-linux-gnu/python3.9/pyconfig.h' file not found
When I open the file that throws the error I see the this line indicating that it's searching for it in the system:
#include <aarch64-linux-gnu/python3.9/pyconfig.h>
I ran sudo find / -name "aarch64-linux-gnu" to see whether I have that file or not and indeed I have this file installed:
user#debian:~$ sudo find / -name "aarch64-linux-gnu"
...
/home/user/toolchains/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/aarch64-linux-gnu/include/c++/8.3.0/aarch64-linux-gnu
find: ‘/run/user/1000/doc’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied
/usr/lib/mesa-diverted/aarch64-linux-gnu
/usr/lib/aarch64-linux-gnu
/usr/share/gdb/auto-load/lib/aarch64-linux-gnu
/usr/share/gdb/auto-load/usr/lib/aarch64-linux-gnu
/usr/include/finclude/aarch64-linux-gnu
/usr/include/aarch64-linux-gnu
I located inside /usr/include/aarch64-linux-gnu and indeed saw /python3.9/pyconfig.h.
The way I did everything is this:
sudo git clone https://github.com/tensorflow/tensorflow.git /home/user/Desktop/official_stuff/tensorflow_src
curl -LO https://storage.googleapis.com/mirror.tensorflow.org/developer.arm.com/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz
mkdir -p ${HOME}/toolchains
tar xvf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -C ${HOME}/toolchains
ARMCC_PREFIX=${HOME}/toolchains/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/aarch64-linux-gnu-
ARMCC_FLAGS="-funsafe-math-optimizations"
cmake -DCMAKE_C_COMPILER=${ARMCC_PREFIX}gcc \
-DCMAKE_CXX_COMPILER=${ARMCC_PREFIX}g++ \
-DCMAKE_C_FLAGS="${ARMCC_FLAGS}" \
-DCMAKE_CXX_FLAGS="${ARMCC_FLAGS}" \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
../tensorflow/lite/
And then I needed to ran dpkg --add-architecture arm64, apt-get update, sudo apt install libpython3-dev:arm64
I simply clicked build ran after connecting my android device. It compiled for a while and then throw the error.
Here is the cmake snippet I ran that contains my tflite inclusion:
set(TENSORFLOW_SOURCE_DIR "" CACHE PATH
"Directory that contains the TensorFlow project" )
if(NOT TENSORFLOW_SOURCE_DIR)
get_filename_component(TENSORFLOW_SOURCE_DIR
"/home/user/Desktop/official_stuff/tensorflow_src" ABSOLUTE)
endif()
add_library(tensorflowlite SHARED IMPORTED)
add_subdirectory(
"/home/user/Desktop/official_stuff/tensorflow_src/tensorflow/lite"
"${CMAKE_CURRENT_BINARY_DIR}/tensorflow-lite" EXCLUDE_FROM_ALL
)
...
target_link_libraries(
my_proj
tensorflow-lite
)
How can I fix this issue?
Note: I got to this point following a series of questions which all resolved:
An undefined error.
Question regarding android build.
More details about how I built everything can be found here. I'm on debian 11.

Android Studio armv7 project

I'm trying to run these projects which uses jni to do a arm assembly call im using android studio but it has external makefiles im a little bit lost
https://github.com/Miouyouyou/ARMv7-Java-JNI-call
https://github.com/Miouyouyou/ARMv7-Java-JNI-return
I am using android studio on windows, when i try to do make using the android studio terminal (using gnu make) i get
armv7a-hardfloat-linux-gnueabi-as -o decypherArcane.o decypherArcane.s
process_begin: CreateProcess(NULL, armv7a-hardfloat-linux-gnueabi-as -o decypher
make (e=2): The system cannot find the file specified.
make: *** [decypherArcane.o] Error 2
i think it will perhaps work if i convert the makefile into a .bat one
This is the makefile (it is outside the root of the android studio project)
`CROSS_COMPILE = armv7a-hardfloat-linux-gnueabi-
LD = $(CROSS_COMPILE)ld.gold
AS = $(CROSS_COMPILE)as
ANDROID_APK_NATIVE_LIB_DIR = ./apk/app/src/main/jniLibs
ANDROID_LIBNAME = libarcane.so
SOURCE = decypherArcane.s
OBJECT = decypherArcane.o
.PHONY: all
all: $(OBJECT)
$(LD) -shared --dynamic-linker=/system/bin/linker --hash-style=sysv -o $(ANDROID_LIBNAME) $(OBJECT)
mkdir -p $(ANDROID_APK_NATIVE_LIB_DIR)/armeabi{,-v7a}
cp $(ANDROID_LIBNAME) $(ANDROID_APK_NATIVE_LIB_DIR)/armeabi
cp $(ANDROID_LIBNAME) $(ANDROID_APK_NATIVE_LIB_DIR)/armeabi-v7a
.PHONY: install
install: all
make -C apk
$(OBJECT): $(SOURCE)
$(AS) -o $(OBJECT) $(SOURCE)
.PHONY: clean
clean:
$(RM) $(OBJECT) $(ANDROID_LIBNAME)
.PHONY: distclean
distclean: clean
$(RM) $(ANDROID_APK_NATIVE_LIB_DIR)/armeabi/$(ANDROID_LIBNAME)
$(RM) $(ANDROID_APK_NATIVE_LIB_DIR)/armeabi-v7a/$(ANDROID_LIBNAME)
`
I've updated these two projects, ARMv7-Java-JNI-return and ARMv7-Java-JNI-call, making the build process slightly easier on Windows.
You'll need :
The Android NDK path in your PATH environment variable.
A Java JDK to compile and install the sample APK
For each project :
Browse the folder where you cloned the repository
Open a Command window here using Shift + Right Click → Open a Command window here
Type mkBuild
If everything goes fine, you should see something like this :
[armeabi] Compile arm : arcane <= decypherArcane.s
[armeabi] SharedLibrary : libarcane.so
[armeabi] Install : libarcane.so => apk/app/src/main/jniLibs/armeabi/libarcane.so
[armeabi-v7a] Compile arm : arcane <= decypherArcane.s
[armeabi-v7a] SharedLibrary : libarcane.so
[armeabi-v7a] Install : libarcane.so => apk/app/src/main/jniLibs/armeabi-v7a/libarcane.so
If that's the case, plug your phone and type the following in the opened Command Window :
cd apk
gradlew installDebug
Again, if everything goes fine, then your phone should have a new Android APP named either Decyph'App or Wild Assembly !. Run the new app and see the results.
Now, if you run into any issue while trying to build, install or run these samples, please open an issue ticket on Github or Gitlab mirrors.

Building pjsip for x86

I want to build pjsip for x86 architecture. I am following this link. In the instructions,
Building PJSIP
Just run:
$ cd /path/to/your/pjsip/dir
$ export ANDROID_NDK_ROOT=/path_to_android_ndk_dir
$ ./configure-android
$ make dep && make clean && make
Notes:
It will build armeabi target, to build for other targets such as arm64-v8a, armeabi-v7a, x86, instead of just './configure-android', specify the target arch in TARGET_ABI and run it with --use-ndk-cflags, for example:
TARGET_ABI=armeabi-v7a ./configure-android --use-ndk-cflags
Also you should adjust ​Application.mk and ​library packaging path (see also #1803).
Are they referring Application.mk in pjsua application?
Yes. There is link in ticket #1803 on changeset 5056:
https://trac.pjsip.org/repos/changeset/5056
Android.mk and Application.mk you can find here: your-pjsip-root-dir/pjsip-apps/src/pjsua/android/jni/Application.mk

PJSIP Library Build Error for Android

Please help me. I try to build PJSIP library in Windows for Android by using Cygwin terminal. I follow steps exactly, but when I write $ ./configre-android I get this error - >
$ ./configure-android
./configure-android: line 3: $'\r': command not found
./configure-android: line 5: $'\r': command not found
./configure-android: line 71: syntax error near unexpected token `$'do\r''
'/configure-android: line 71: ` for i in `$NDK_OUT`; do
I used this steps to build sources are
Download sources from PJSIP site. Pay attention if you will compile
on Windows machine download .zip file, if on Unix machine (including
OS X) then download .bz2 file.
Go to pjlib/include/pj/ from the downloaded sources. Create (or
overwrite) a file called config_site.h. Copy the following code
snippet
#define PJ_CONFIG_ANDROID 1
#include <pj/config_site_sample.h>
Open Cmd or Terminal
Go to pjsip root folder (the downloaded sources)
$ cd /path/to/your/pjsip/dir
Export bash var ANDROID_NDK_ROOT as a environment variable.
Variable value should be the path of android ndk directory.
$ export ANDROID_NDK_ROOT=/path_to_android_ndk_dir
Perform build for target armeabi
$ ./configure-android
If you need to perform build for target arm64-v8a do $
TARGET_ABI=armeabi-v8a ./configure-android --use-ndk-cflags
target armeabi-v7a do $
TARGET_ABI=armeabi-v7a ./configure-android --use-ndk-cflags
target x86 do $ TARGET_ABI=x86 ./configure-android --use-ndk-cflags
Compile sources
$ make dep && make clean && make
This fixed problem for me:
tr -d '\015' < configure-android > configure-android2
After this launch configure-android2, not configure-android

Build script for Android NDK in linux

How can I build my source for android with NDK.
Already I download ndk and I don't know how can I set arch compiler path.
This is my "build-for-android.sh" code:
#!/bin/sh
cairo=system
curl=system
pal=android
alsa=no
pulse=no
sles=yes
ffmpeg=yes
gallium=no
egl=yes
glx=no
PKG_CONFIG_PATH=$MOONLIGHT_PREFIX/lib/pkgconfig
if [ -d /usr/X11/share/aclocal ]; then
export ACLOCAL_FLAGS="-I /usr/X11/share/aclocal"
fi
./autogen.sh --host=arm-linux-androideabi --prefix=$MOONLIGHT_PREFIX --with-manual-mono=yes --with-testing=no --enable-browser-support --disable-desktop-support --with-unwind=no --with-ffmpeg=$ffmpeg --with-alsa=$alsa --with-pulseaudio=$pulse --with-opensles=$sles --with-pal=$pal --with-curl=$curl --with-cairo=$cairo --with-gallium-path=$gallium --enable-sdk=no --with-egl=$egl --with-glx=$glx CFLAGS="-DPLATFORM_ANDROID -I$MOONLIGHT_PREFIX/include $CFLAGS" LDFLAGS="-L$MOONLIGHT_PREFIX/lib $LDFLAGS" CXXFLAGS="-fno-rtti -DPLATFORM_ANDROID -I$MOONLIGHT_PREFIX/include $CFLAGS"
make $#
when I run it I get error below:
checking for arm-linu-androideabi-g++... no
checking for arm-linu-androideabi-c++... no
checking for arm-linu-androideabi-gpp... no
checking for arm-linu-androideabi-aCC... no
checking for arm-linu-androideabi-cc... no
.
.
.
.
I can see them in ~/Android/android-ndk-r8b/toolchains/arm-linux-androideabi-4.4.3/prebuild/linux-x86/bin/* directory.
OK. I found it.:
First, a standalone toolchain is created to make the configure script easier to use
~$ android-ndk-r5b/build/tools/make-standalone-toolchain.sh --platform=android-8 --install-dir=android-8-toolchain
Next, the toolchain's bin directory is added to the PATH.
~$ export PATH=$PATH:~/android-8-toolchain/bin/

Categories

Resources