Android NDK r11c clang toolchain with precompiled header issue - android

I just updated my NDK to the latest r11c and got this issue while compiling the PCH
clang++: error: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
I have specified my pre-compiled header file via LOCAL_PCH variable and the make script was going to compile it into a .pch file. But it seems clang denied this compile because of the suffix of this file is .h
How can I fix my Android.mk file to the PCH works with the r11c NDK?

Well, I just change the suffix of my precompiled header files from .h to .hpp and this issue is solved.

Related

Android ndk file not found on github actions

I am trying to implement CI on app which contains native code in C++ using github actions
When i am running workflow it's says that there is no headers near the .cpp, but it is here and i have setted include directories in build.gradle and Android.mk file, the build is fine on local PC(windows)
[armeabi-v7a] Compile++ thumb: samp <= CAuthentication.cpp In file
included from
/home/runner/work/client/client/app/src/main/cpp/CAuthentication.cpp:3:
/home/runner/work/client/client/app/src/main/cpp/main.h:23:10: fatal
error: 'vendor\RakNet\SAMP\samp_netencr.h' file not found
#include "vendor\RakNet\SAMP\samp_netencr.h"
file CAuthentication.cpp is in the same directory as directory "vendor"
I also tried to set environment variable in github job but it does not help
If you're using backslashes in your include directives as the error seems to suggest, try to change them into forward slashes:
#include "vendor/RakNet/SAMP/samp_netencr.h"
Also check the path for case correctness. Windows has a case-insensitive filesystem, while the CI might be running some form of Linux.

Compiling stressapptest on NDK for Android

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.

PJSIP + FFMPEG build error

I'm trying to build PJSIP with FFMPEG for Android.
For building FFMPEG with rtmp and openssl, I use this project:
https://github.com/cine-io/android-ffmpeg-with-rtmp
and it compiles pretty well.
Then I'm compiling pjsip 2.6 with ffmpeg. Here is the part from my build file:
APP_PLATFORM=android-${TARGET_ANDROID_API} NDK_TOOLCHAIN_VERSION=4.9 TARGET_ABI=$arch ./configure-android --use-ndk-cflags \
--with-ssl="${OPENSSL_BUILD_OUT_PATH}/libs/${arch}" \
--with-ffmpeg="${BASE_DIR}/ffmpeg-output"
>>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1
My target ABI is armeabi.
Also, i've defined these two flags:
#define PJMEDIA_HAS_VIDEO 1
#define PJMEDIA_HAS_FFMPEG 1
But the build failed with a bunch of these two errors:
error: cannot find -lbz2
error: cannot find -lasound
A have libasound2-dev and bzip2 installed on my Ubuntu 16.04 LTS VM.
Before that, I've successfully made pjsip builds with OpenH264 with no errors like this.
Is there any way to tell linker(or whatever it is) how to find those packages?
Solve that problem (thx #NandhaKumar) by compiling .a libs for each library above and adding them to pjsip library path:
Build .a libs.
Copy libs to {PJPROJECT}/third_party/lib/ folder.
Go to the build.mak.in file in your PJSIP project folder.
Add the following lines:
APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libbz2.a
APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libasound.a
In my case (and I still don't know why) second line and defining another line
(APP_THIRD_PARTY_LIBS += -lsound or APP_THIRD_PARTY_LIBS += -lasound) doesn't help, so I just copied this library into the android_ndk folder:
android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9/libasound.a

#include <exception> - No such file or directory

I am currently trying compiling GnuTLS (for wget) for Android with the Android cross-compile toolchain.
I already fixed many missing-library errors, but now I get the error
./includes/gnutls/gnutlsxx.h:26:21: fatal error: exception: No such file or directory
#include <exception>
I am using "arm-linux-androideabi-gcc (GCC) 4.9 20140827 (prerelease)" and am using this script https://gist.github.com/z3ntu/57b95b02ebe8e153d5a8 for settings up the env-variables.
You want to run the following command which will tell you where gcc's pre-processor is. Then ask that pre-processor here it's looking for C++ header files:
gcc -print-prog-name=cc1plus -v
then tweak your setup accordingly.
Actually I solved it myself... (still thanks for the help everybody!)
So for all who wonder how to compile GnuTLS for Android:
Create a standalone toolchain: Execute build/tools/make-standalone-toolchain.sh --platform=android-21 --install-dir=<your_directory> --toolchain=arm-linux-androideabi-4.9 --stl=gnustl from the NDK root dir (maybe ~/Android/Sdk/ndk-bundle/)
Compile it with extra -lgnustl_shared in your LDFLAGS.

Android NDK doesn't support header files?

This page has instuctions for compiling iwlist and other commands for Android:
https://code.google.com/p/haggle/wiki/WirelessTools
Unfortunately I'm getting the same type of error as the commenter on that page:
Android NDK: WARNING: Unsupported source file extensions in /home/simon/Android-SDK/wireless_tools.29/Android.mk for module iwlist Android NDK: iwlib.h
When I remove the iwlib.h from the LOCAL_SRC_FILES of the Android.mk, it doesn't show that warning, but it still fails with the same error:
./iwlist.c:633:7: error: 'IW_EV_LCP_PK2_LEN' undeclared (first use in this function)
This is undeclared because it is in the iwlib.h file it's warning about.
So why does the Android NDK not recognize header .h files?
To build the libraries, you unpacked the gz file, and ran make, didn't you? Or you simply renamed wireless.22.h? Anyways, before you runndk-build, you have a wireless.h file in the package directory. Add the following two lines to the end of this file:
#undef IW_EV_LCP_PK_LEN
#undef IW_EV_POINT_PK_LEN
And remove the iwlib.h from the LOCAL_SRC_FILES of the Android.mk. #Gabe is right, header files should not be compiled separately. In iwlist.c you will find line 14:
#include "iwlib.h"
You normally don't compile header files. You include them in a .c or .cpp file that you do compile. But you wouldn't pass them into the compiler as a source file.

Categories

Resources