How To Correctly Build libdatachannel For Android - 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]

Related

How to include <glib.h> in android cmake project

I have created an android project on windows with ndk template. I want to include ndk-build project into android studio. This ndk-build project is working fine separately when I run ndk-build command.
My requirement is to convert and use it in android studio so that I can debug the code on android mobile. At this time I am just using share library (so file) and call the required function from adb shell.
I have copied all the source files of my separate ndk project into my android studio project and also added them into native-lib(created by default by android studio) library. But, I am getting an exception on including glib.h.
I am not sure actually how to resolve it.
Please suggest something.
Read this:https://developer.gimp.org/api/2.0/glib/glib-compiling.html
I usually use the following:[To complie]
gcc `pkg-config --cflags --libs glib-2.0 dbus-glib-1` progname.c
Hope this will help you.

Building capicxx-core-runtime for Android

We are trying to build capicxx-core-runtime for an ARM based platform running Android Pie. It's an open source IPC framework which is part of the GENIVI initiative by major automotive OEM's. Our AIM is to bring the IPC framework into our Android system.
The git repo is placed here https://github.com/GENIVI/capicxx-core-runtime.git
I am using the Android NDK version r17b and building using the following command to configure the cmake based build.
cmake -DCMAKE_TOOLCHAIN_FILE=/home/hp/downloads/android-ndk-r17b/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_NATIVE_API_LEVEL=27 ../
When I compile using 'make', I see the individual cpp files are compiled, but I am getting following errors during linking as shown in the link below.What is the configuration that I may be missing.
Linker error log
the capicxx-core-runtime is building a shared library, so you need to resolve all of it's internal symbols, including the c++ runtime.
To quickly test this: edit the capicxx-core-runtime CMakeLists.txt to link the c++_shared runtime, line 130:
target_link_libraries(CommonAPI PRIVATE ${DL_LIBRARY} ${DLT_LIBRARIES})
becomes
target_link_libraries(CommonAPI PRIVATE ${DL_LIBRARY} ${DLT_LIBRARIES} c++_shared)
and rerun your cmake command and make command.
It seems that capicxx-core-runtime can be buildable now for Android (both NDK and AOSP) out the box, please see corresponding pull requests: https://github.com/GENIVI/capicxx-core-runtime/pulls?q=author%3Ankh-lab+
Also here is simple example for AndroidStudio how it could be used with vSOME/IP transport: https://github.com/nkh-lab/ndk-capi-hello-world

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.

Creating standalone tool-chain for android NDK

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.

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