Creating standalone tool-chain for android NDK - android

I am trying to build latest FFmpeg along with halfninja's code for android since some of the options are not available in older versions.I updated FFmpeg packages and tried to run ./create_toolchain.sh.
I am getting the following error:
user#user:~/Android/android-ffmpeg-x264/Project/jni$ ./create_toolchain.sh
~/Android/android-ffmpeg-x264/Project/jni ~/Android/android-ffmpeg-x264/Project/jni
/home/user/android/tools:/home/user/android/platform-tools:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/user/android/tools:/home/user/android/platform-tools:/home/user/Android/android-ndk-r8e:/home/user/Android/android-ffmpeg-x264/Project/jni/toolchain/bin
Host system 'linux-x86' is not supported by the source NDK!
Try --system=<name> with one of: linux-x86_64
My android NDK version is android-ndk-r8e.
I am facing problems in building latest version of FFmpeg by creating standalone toolchain.
Any help is appreciated.

Your system is 64 bit. The --system=linux-x86_64 should be the parameter of make-standalone-toolchain.sh which is part of the NDK. Like this:
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --system=linux-x86_64 ...
I don't know this create-toolchain.sh but I am sure there's an invocation to make-standalone-toolchain in it. That's where you have to add the parameter.

Related

How To Correctly Build libdatachannel For Android

I've been trying to build libdatachannel, the C/C++ standalone implementation of WebRTC, for an Android project. I've tried both build options given :
POSIX-compliant operating systems, and
Build directly with Make.
I, however, keep getting the following error when I try to build the project in Android Studio C/C++ :
ld: error: ../../../../libs/libdatachannel/libdatachannel.a(wstransport.o) is incompatible with aarch64linux.
Would you please advise on how to get it working? How can I build it so that I get ARM builds for Android? Any way you can help will be greatly appreciated.
Thank you in advance.
Answered here
It looks like libdatachannel is not built for the required ARM64 architecture. The easiest way to build it for the right target is to use the Android NDK toolchain file, something like:
$ cmake -B build -DUSE_GNUTLS=0 -DUSE_NICE=0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=[Path to the NDK]/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=[min SDK version]

Android Studio cannot link against -l1

I have just formatted my computer and reinstalled android studio and sdk & ndk. I've created a new project but now I can't build it with c++ source because I keep getting this error:
.../x86_64-linux-android/bin\ld: error: cannot find -l1
I am not event linking a library called "1". What is it for?
Seems like latest ndk or android-studio has some sort of naming problem or I had a problem when installing it.
I was linking the android library
find_library(ANDROID android)
target_link_library(... ${ANDROID})
but it seems like ${ANDROID} was set to 1. I set it to "android" by hand and now it compiles as expected.
One of the first things the CMake toolchain file does is set(ANDROID TRUE) to indicate that the build is targeting Android. You can't use ANDROID as a variable name in your CMakeLists.txt because it's already used. Best to assume that anything prefixed with ANDROID is part of the implementation.

No tool chain is available to build for platform 'armeabi-v7a'

While running the sample NDK program Native Audio in Android studio in Arch Linux I get the following error:
Error:Execution failed for task ':app:compileNative-audio-jniArmeabi-v7aDebugSharedLibraryNative-audio-jniMainC'.
No tool chain is available to build for platform 'armeabi-v7a':
- Tool chain 'ndk-clang' (Clang): Could not determine Clang version: failed to execute clang -dM -E -.
How can I correct this error? Do I need to make a tool chain so that i can run the sample ndk program?
Two solutions:
1) download ndk-r12 from https://github.com/android-ndk/ndk/wiki, scroll down to "current beta release", and point your android studio to use that version from native-audio/local.properties file
2) use your current ndk as-is, but comment out the following from native-audio/app/build.gradle
toolchain = 'clang'
then it will use gcc to build
Thanks to ggfan for answering this question in github
The reason could be in absence of some library required by ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang. Like:
error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
Try to run it, check the error and install all the requirements.
For example, on Fedora it would be sudo dnf install ncurses-compat-libs for that particular library.

Use ARMCC to compile Android native library

I've been working on an Android project which has several native C++ libraries. Compiling and debugging using Eclipse with ADT plugin works well. Obviously Android NDK uses arm-linux-gnueabi-gcc of some version to compile the native libraries.
Since I've been using NEON intrinsics heavily, I would like to try to compile the native libraries with ARM's official compiler armcc. I read everywhere that armcc is supposed to give better optimized code when using intrinsics. So I downloaded the trial version of DS-5 from ARM website, just to try and see whether there's really any speed difference.
The DS-5 seems to be just a modified version of Eclipse that uses the ARMCC toolchain, so I installed the ADT plugin. But when I compile using DS-5, it seems that the code is still generated using gcc rather than armcc.
Do you have any idea how to force DS-5 or Eclipse to build the Android native code using armcc? Or is it possible (and how) to build the static NDK libraries from command line and then replace the libraries in my project, so they get deployed to the testing phone?
ARM DS-5 Community Edition doesn't include ARM compiler (armcc).
If you could get hold of armcc best would be to separate your processing heavy algorithms to individual compilation units (separate C files), build them with armcc as you would do for any compilation unit. When you get the object files, convert them into an archive then use that in Android.mk as LOCAL_STATIC_LIBRARIES += <your_archive>.
You can't use armcc plainly to build Android compatible libraries mostly because of Bionic dependencies, I think.
You can use armcc to build Android compatible static libraries even though Android has a different C library (bionic). The key is the --library_interface flag for armcc. According to the documentation:
Use an option of the form --library_interface=aeabi_* when linking with an ABI-compliant C library. Options of the form --library_interface=aeabi_* ensure that the compiler does not generate calls to any optimized functions provided by the ARM C library.
In addition, there are a few more flags to ensure compatibility with the Android EABI resulting in the following command for an Android armeabi-v7a target:
armcc --library_interface=aeabi_clib --wchar32 --enum_is_int --no_hide_all --cpu=7-A --fpu=softvfp+vfpv3 -c -o libfunc.o libfunc.c
You can then use armar --create libfunc.a libfunc.o to create a static library that can be linked with the Android NDK as LOCAL_STATIC_LIBRARIES.
I have successfully tested this with Android NDK r10d on Android KitKat 4.4.2.

how to make scan-build(clang) work together with prebuilt android gcc?

Im trying to carry out static source code analysis for my android native project written in C/C++ using scan-build.
I tried the instructoins on this page(http://clang.llvm.org/get_started.html#build) for building and running scan-build. All these are done in Ubuntu 10.10, 64bit version.
Since I'm building my project in android source, the compilers used are gcc and g++ located in android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/.
It is said that I can configure scan-build to work with gcc/g++ using --use-c++ and --use-cc options.
But when I run the command: (./run_scanbuild.sh is the build script)
scan-build --use-cc=/home/chulwoo/8655_GB_AU_2_30/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-gcc --use-c++=/home/chulwoo/8655_GB_AU_2_30/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-g++ ./run_scanbuild.sh
it says :
scan-build: 'clang' executable not found in '/home/chulwoo/Clang/llvm/tools/clang/tools/scan-build/bin'.
scan-build: Using 'clang' from path: /home/chulwoo/Clang/build/Debug+Asserts/bin//clang
Seems the --use-c++ and --use-cc options are simply ignored.
Does any one know how to make scan-build work with android prebuilt gcc/g++ ?
Or, is it feasible to build my project using Clang in android?
Thanks in advance.
Jin.
Okay ,this was a stupid question.
Just build it with following command, and it surely will generate static-analysis result.
Here lets assume that gcc is used for building.
scan-build gcc ...whatever you wanna give as options...
The scan-build is really a nice tool, hope you guys enjoy it.

Categories

Resources