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/
Related
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.
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
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
I'm trying to configure valgrind for android on Windows 7. I'm using guide from this site, but there is a problem with C compiler while configure. I'm using cygwin.
Error:
configure:3531: error: in /cygdrive/c/Tools/valgrind-3.9.0':
configure:3533: error: C compiler cannot create executables
Script:
#!/bin/bash
export NDKROOT=C:/Tools/AndroidNDK-r6
export HWKIND=generic # A generic Android device. eg, Pandaboard
export AR=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-ar.exe
export LD=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-ld.exe
export CC=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc.exe
CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm -DANDROID_HARDWARE_$HWKIND" \
CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" \
./configure --prefix=/data/local/Inst \
--host=armv7-unknown-linux --target=armv7-unknown-linux \
--with-tmpdir=/sdcard
make
make install
and config.log file
Obviously, there's a kind of a problem executing the compiler from within the NDK folder. The log file states:
configure:3422: checking for C compiler version
configure:3431: C:/Tools/AndroidNDK-r6
/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc.exe
--version >&5
./configure: line 3433: C:/Tools/AndroidNDK-r6
/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc.exe
: No such file or directory
So next you want to make sure that the path actually exists and the compiler executable is executable indeed. You can try yourself to type directly in cygwin shell:
C:/Tools/AndroidNDK-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc.exe -v
...and see what happens.
https://github.com/n0d3/lk – this is the repository holding source code for clk 1.5, which is a bootloader for Android and which I am trying to compile. Compiled packages can be found; however, I need to customize it. How can I compile it?
Running make returns the following:
$ make
makefile:22: *** No project specified. Use "make projectname" or put "PROJECT := projectname" in local.mk. Stop.
Running make htcleo returns the following:
$ make htcleo
make[1]: Entering directory '/cygdrive/c/Users/Domas/lk'
make[1]: arm-eabi-gcc: Command not found
LIBGCC =
CFLAGS = -O2 -g -fno-builtin -finline -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function -include ./build-htcleo/config.h -ffunction-sections -fdata-sections -mlittle-endian -mfpu=neon -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -mthumb-interwork -mthumb -D__thumb__
including app/aboot dev/battery dev/fbcon dev/keys lib/debug lib/devinfo lib/heap lib/libc lib/ptable
generating build-htcleo/config.h
compiling arch/arm/start.S
make[1]: arm-eabi-gcc: Command not found
arch/arm/compile.mk:30: recipe for target 'build-htcleo/arch/arm/start.o' failed
make[1]: *** [build-htcleo/arch/arm/start.o] Error 127
make[1]: Leaving directory '/cygdrive/c/Users/Domas/lk'
makefile:15: recipe for target 'make-make' failed
make: *** [make-make] Error 2
As you can see the make breaks on make[1]: arm-eabi-gcc: Command not found. I was able to compile an older version (which had a different compilation process) by using a CodeSourcery toolchain, which has arm-none-eabi-gcc.exe, but not arm-eabi-gcc.exe, which seems to be needed to compile this version.
Note:
I appreciate that this might not be a popular type of question here on SO; however, I've been banging my head on this one the whole day, and could really use some guidance.
I managed to compile it. What I did was find a git repository that had a compilation script and some additional files for compilation along side the source code, but it was the old source code. So I downloaded this project, and replaced the source code with a recent one, and the compilation script worked. Below instructions, most of it is copy paste from xda forums:
Download this zip archive here: https://github.com/cedesmith/cLK/archive/master.zip
It's the old source code, but it has the necessary scripts to make compilation easy.
Unzip the archive so that the compile script's path is ~/cLK/compile
Delete the ~/cLK/lk subdirectory (this is the old source code).
Download the new source code: git clone https://github.com/n0d3/lk
Now you should have the new source code in ~/cLK/lk. On to the actual compilation: this will depend on whether you're on Linux or Windows:
Linux
on Debian:
sudo apt-get update
sudo apt-get install gcc make git wget unzip zip libc6-dev-amd64 libc6-dev
on Fedora:
yum install gcc make git wget unzip zip
Now download the CodeSourcery toolchain:
wget http://www.codesourcery.com/sgpp/lite/arm/portal/package5353/public/arm-none-eabi/arm-2009q3-68-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
tar xvfj arm-2009q3-68-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
export PATH=$HOME/clk/arm-2009q3/bin:$PATH
Finally, compile:
cd ~/cLK
./compile clean
If everything goes well, you'll find the RUU_signed in this folder: bin/RUU_signed.nbh
Windows
You'll need Cygwin:
Download, the following file, and execute it http://www.cygwin.com/setup.exe
Click Next
Click "Install from internet" and click Next
Click Next (to accept the default directory to install)
Click Next (to accept the default directory for local Package directory)
Click "Direct Connection", and click Next
Select a "local mirror", and click Next
Now in the search bar, you need to search for the following things to install
gcc
make
git
wget
zip
unzip
Once selected click Next to continue, and Finish
Fire up the cygwin terminal (mintty); the following commands probably don't work in cmd.exe.
Now download CodeSourcery toolchain and yang:
wget http://www.codesourcery.com/sgpp/lite/arm/portal/package5354/public/arm-none-eabi/arm-2009q3-68-arm-none-eabi-i686-mingw32.tar.bz2
tar xvfj arm-2009q3-68-arm-none-eabi-i686-mingw32.tar.bz2
wget http://htc-flasher.googlecode.com/files/yang-1.1_win32.zip
cd cLK/bin
rm -rf yang
mkdir yang
unzip ../../yang-1.1_win32.zip yang/yang.exe
mv yang/yang.exe .
cd ..
sed -i s/yang/yang.exe/g compile
And finally, compile:
export PATH=$HOME/arm-2009q3/bin:$PATH
cd ~/cLK
./compile clean
Now your RUU_signed.nbh will be located in the following folder bin/RUU_signed.nbh