I tried to build android-vlc and ijkPlayer using Git, and after following the steps and making the required sdk and ndk exports for each one, both lead me to the same error message through Git-Bash which is:
You need NDKr9 or later
I have NDKr9b and NDKr10d and I got this error message with both of them, and after having a look at android-vlc sdk source code I found that it just checking the /RELEASE.TXT file in the ndk provided path:
# try to detect NDK version
REL=$(grep -o '^r[0-9]*.*' $ANDROID_NDK/RELEASE.TXT 2>/dev/null|cut -b2-)
case "$REL" in
9*|10*)
GCCVER=4.8
CXXSTL="/"${GCCVER}
;;
7|8|*)
echo "You need the NDKv9 or later"
exit 1
;;
esac
and when checking it my self for NDK10, I found that it only contains one line which is:
r10d (64-bit)
and in NDK9 it is:
r9b
which supposed to make the code run without problems in both cases, so what am I missing here?
p.s. I came across this question which provides the same problem but it's answer doesn't work with me.
Related
I think I've read every suggestion on the internet at this point to no avail, so I'm hoping I can get some help here.
Repro
git clone https://github.com/banool/aclip.git
cd aclip/frontend/native
cargo ndk -t armeabi-v7a -o ../android/app/src/main/jniLibs build
The code in question: https://github.com/banool/aclip.
Relevant env:
PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig/
LDFLAGS=-L/opt/homebrew/opt/openssl#1.1/lib
CPPFLAGS=-I/usr/local/opt/openssl#1.1/include
CFLAGS=-I/opt/homebrew/opt/openssl#1.1/include
ANDROID_NDK_HOME=/Users/dport/Library/Android/sdk/ndk
Output
Running the above gives me this: https://gist.github.com/d2564965bbd5e4d8bf72c3132c87255f.
Some thoughts on what's going on here:
I see it says NDK API level: 21. Is this level not the same as the NDK level, which as you can see in the previous line is 24?
I have tried setting PKG_CONFIG_SYSROOT_DIR to the NDK directory. That gives me instead this rather cryptic error: https://gist.github.com/b28eae5f666fccaffe80278a5a8a80e1. I wonder if there is a better directory to use.
I did everything here relevant to the second part, where I'm trying to use a newer NDK: http://cjycode.com/flutter_rust_bridge/template/setup_android.html.
I have set the libunwind stuff suggested here: http://cjycode.com/flutter_rust_bridge/template/setup_android.html. That helped with the gcc error in the second gist here, but I've still got the ssl and crypto errors.
Any tips on how to proceed would be very much appreciated.
Thanks!
For me I was able to skirt around the issue by doing this.
First, figure out what openssl crate version we're relying on:
$ cargo tree --target=x86_64-unknown-linux-musl -i openssl-sys | grep openssel
openssl-sys v0.9.74
└── openssl v0.10.40
Then add something like this to your Cargo.toml:
openssl = { version = "0.10.40", features = ["vendored"] }
This avoids the need for the system openssl.
How do I compile and use Boost for the Android NDK? I've tried everything I've found online, from Boost for Android to compiling it myself with the bjam file. However, I do not succeed. When I try compiling it with bjam, I get the following error:
error: toolset gcc initialization:
error: version 'androidR10e' requested but 'g++-androidR10e' not found and version '4.2.1' of default 'g++' does not match
error: initialized from /path/to/android-ndk-r10e/sources/boost/tools/build/v2/user-config.jam:86
Has anyone successfully used Boost with Android NDK R10e?
And when I can compile it, how should I do to use it in my Android app project?
We managed to compile it for NDKr10d. It should be the same for NDKr10e.
The project-config.bjam should point to the gcc compiler from the NDK. Ours looks like this :
import option ;
using gcc : arm : D:\\android\\ndk\\toolchains\\arm-linux-androideabi-4.9\\prebuilt\\windows-x86_64\\bin\\arm-linux-androideabi-g++.exe ;
option.set keep-going : false ;
Then just compile with b2, telling paths to android includes :
b2 --reconfigure <your options>
toolset=gcc-arm
include=<ndk folder>\sources\cxx-stl\gnu-libstdc++\4.9\include
include=<ndk folder>\sources\cxx-stl\gnu-libstdc++\4.9\libs\<target platform>\include
include=<ndk folder>\platforms\<android api version>\arch-arm\usr\include
install --libdir=stage\lib\<target platform>
We're about to move to ndkr10e. Could you tell if boost still works with it ? :)
The simplest way would be to use CrystaX NDK, which contains already built and ready-to-use Boost libraries. And here are examples how to use Boost with CrystaX NDK: 1, 2
Following the boost directions, I was able to build boost 1.60 with NDKr10e on Ubuntu 12.04 (although I suspect very little depends on the host system). Here are my notes:
get and unpack boost source tarball (i used 1.60): boost_1_60_0.tar.bz2
moskewcz#maaya:/scratch/moskewcz/android/src$ ll
total 74M
drwx------ 10 moskewcz moskewcz 4.0K Mar 9 14:14 boost_1_60_0
-rw-rw-r-- 1 moskewcz moskewcz 74M Jan 5 11:15 boost_1_60_0.tar.bz2
follow boost instructions in getting started on unix "Build Custom Binaries" section
use a fresh, empty root to install b2 i.e. /scratch/boost-build-root; use usr as prefix; again following the boost instructions:
moskewcz#maaya:/scratch/moskewcz/android/src/boost_1_60_0/tools/build$ ./bootstrap.sh
moskewcz#maaya:/scratch/moskewcz/android/src/boost_1_60_0/tools/build$ ./b2 install --prefix=/scratch/moskewcz/android/boost-build-root/usr
put b2 in path (again as per instructions)
export PATH=/scratch/moskewcz/android/boost-build-root/usr/bin:$PATH
in some jamfile (i had no ~/user-config.jam, so i created one and used that, maybe there's a better choice of jamfile to create/edit) add some jam-code (?) to define a gcc version (toolset) pointing to a g++ from a standalone toolchain. note that this is a toolchain created with the NDK in the normal fashion following its 'create a standalone toolchain' directions. i am NOT pointing to a g++ inside the NDK itself (that may or may not work, i dunno):
import option ;
using gcc : arm_linux_android_4.9 : /scratch/android-stc/bin/aarch64-linux-android-g++ ;
option.set keep-going : false ;
go to boost project root and build, mostly as per directions. --build-dir may be optional? also added -j8 to do || build
moskewcz#maaya:/scratch/moskewcz/android/src/boost_1_60_0$ b2 -j8 --build-dir=bin.v2 toolset=gcc-arm_linux_android_4.9 stage
note that this tries to build both static and shared libs by default, but building shared libs fails due to android not having librt.so -- according to my research, people claim that under android (some of?) the functionality of librt.so is inside libc.so -- so it may be okay to simply remove -lrt from the linking steps in order to build shared libs for android. i did not attempt this. see:
https://code.google.com/p/android/issues/detail?id=5730
Building Boost for Android with error "cannot find -lrt"
I only managed to build with 10d. Cross compiling Linux->Android using Boost for Android worked straight away with that.
To download a slightly outdated ndk, as not all ndk are immediately supported by Boost for Android, you can use this guide: Where do I find old versions of Android NDK?
Note: I also wanted to specify the toolchain. I had to do it in 2 places:
In build-android.sh, just after the line mentioned here above:
TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.9}
In the command line
bash build-android.sh [ndk location] --toolchain=arm-linux-androideabi-4.9
In fact, it worked better when I specified exactly which boost components I wanted with --with-libraries=[comma separated list].
If instead I would build everything, I would get:
...failed updating 38 targets...
...skipped 6 targets...
...updated 10568 targets...
ERROR: Failed to build boost for android!
Done!
Here: http://silverglint.com/boost-for-android/ you can find a simple and painless new way to build a modern (eg 1.64.0) version of boost for android.
Works with clang and gcc.
Also included is a sample app that shows you how to use the boost binaries thus built.
I tried building i686-linux-android-gfortran using build-gcc.sh following this
(it's for androdindk-7b) but I get error about link.h. I added link.h from here, but it gives further more errors.
Has anyone tried enabling i686-linux-android-gfortran for x86 Android?
From https://groups.google.com/forum/#!msg/android-ndk/QR1qiN0jIpE/g0MHkhTd4YMJ as selalerer suggested. I didn't try this, so I'm posting as a community wiki for reference purposes.
Fortran for x86 Android
=================
The guide is based on this one, many thanks to Phil:
Compiling Android NDK with Objective-C-enabled gcc errors
1) Download and unpack Android NDK 'android-ndk-r8c', (the older -r8b NDK won't work due to missing link.h!):
wget http://dl.google.com/android/ndk/android-ndk-r8c-linux-x86.tar.bz2
2) Create somewhere a folder called 'toolchain-src' (e.g. inside the folder android-ndk-r8c),
'cd' to this new folder
3) Make sure to have git installed ('yum install git' or whatever..) and download
the toolchain sources:
git clone https://android.googlesource.com/toolchain/build.git
git clone https://android.googlesource.com/toolchain/gmp.git
git clone https://android.googlesource.com/toolchain/gdb.git
git clone https://android.googlesource.com/toolchain/mpc.git
git clone https://android.googlesource.com/toolchain/mpfr.git
git clone https://android.googlesource.com/toolchain/expat.git
4) Create the folder 'binutils', 'cd' to this directory, unpack
binutils-2.23 there:
wget ftp.gnu.org/gnu/binutils/binutils-2.23.tar.gz
tar -xvzf binutils-2.23.tar.gz
You should now have a folder toolchain-src/binutils/binutils-2.23
5) Change to folder toolchain-src/build, edit the Makefile.in, changing the line:
--with-gnu-as --with-gnu-ld --enable-languages=c,c++
to
--with-gnu-as --with-gnu-ld --enable-languages=c,c++,fortran
6) In the file android-ndk-r8c/build/tools/build-mingw64-toolchain.sh change the line:
var_append GCC_CONFIGURE_OPTIONS "--enable-languages=c,c++"
to
var_append GCC_CONFIGURE_OPTIONS "--enable-languages=c,c++,fortran"
7) In the file android-ndk-r8c/build/tools/build-gcc.sh, change the line:
EXTRA_CONFIG_FLAGS=$EXTRA_CONFIG_FLAGS" --disable-libquadmath --disable-plugin"
to
EXTRA_CONFIG_FLAGS=$EXTRA_CONFIG_FLAGS" --disable-libquadmath --disable-libquadmath-support --disable-plugin"
8) In the file android-ndk-r8c/build/tools/build-host-gcc.sh, change the line:
ARGS=$ARGS" --enable-languages=c,c++"
to
ARGS=$ARGS" --enable-languages=c,c++,fortran"
And change the line
ARGS=$ARGS" --disable-libquadmath --disable-plugin --disable-libitm --disable-bootstrap"
to
ARGS=$ARGS" --disable-libquadmath --disable-libquadmath-support --disable-plugin --disable-libitm --disable-bootstrap"
9) Build your new toolchain:
/your/path/to/android-ndk-r8c/build/tools/build-gcc.sh -j1 --gmp-version=5.0.5 --mpfr-version=2.4.2 --mpc-version=0.8.1 --binutils-version=2.23 --gdb-version=7.3.x /your/path/to/toolchain-src /your/path/to/android-ndk-r8c x86-4.7
(don't worry about messages like 'expr: warning: unportable BRE:')
10) And go down to your knees in front of the screen, praying to the Lord that somehow these
countless configure scripts doing checks that nobody needs, using an ugly shell language
that cooks your brain with indentation going from right to left, will somehow manage to
compile a zillion of far too small files (so that 10% of the time is spent on compilation
and 90% on starting up GCC), and after an hour of watching progress with
tail -F /tmp/ndk-YourUserName/build/toolchain/config.log
your toolchain will be magically ready. You'll find it in the android-ndk-r8c/toolchains folder.
11) Finally, 'cd' to the folder
'/your/path/to/android-ndk-r8c/toolchains/x86-4.7/prebuilt/linux-x86/i686-linux-android'
and run this command:
ln -s ../libexec libexec
Without this command, it may happen that g++ raises the error message
"g++: fatal error: -fuse-linker-plugin, but liblto_plugin.so not found".
Using strace, I found that g++ looks in the wrong folder, but the link
above lets it find the file liblto_plugin.so nevertheless.
And here are a few lessons learned on the way, so that Google finds this page:
*) To speed up the compilation, you can remove the '-j1'. But only after you got
it to work once, since building in parallel on multiple CPU cores was reported to
cause additional troubles.
*) The error message "Link tests are not allowed after GCC_NO_EXECUTABLES" shows up
when linking fails for x86 (works for ARM). The reason is that GCC does not include
the proper ANDROID_STARTFILE_SPEC and ANDROID_ENDFILE_SPEC from
gcc-4.6.1/gcc/config/linux-android.h. GCC 4.6.1 only specifies them for ARM, but not
for i386, GCC 4.8.0 however does. The GCCs downloaded from Google also do,
so best use Google's GCC.
*) The error message "fatal error: link.h: No such file or directory" also happens
with Google's GCC, and apparently (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50877)
only when you enable additional languages like objc or fortran.
The bug thread is here: http://gcc.gnu.org/ml/gcc-bugs/2012-08/msg00494.html
MIPS has link.h in android-ndk-r8b/platforms/android-9/arch-mips/usr/include
In android-ndk-r8c, link.h is now also present in android-9/arch-x86/usr/include/link.h,
so this bug was fixed.
*) The error message "fatal error: quadmath_weak.h: No such file or directory":
It also happens with the latest gcc-4.8, so we can just continue using Googles GCC 4.7.
Google itself uses --disable-libquadmath, but we additionally need --disable-libquadmathsupport
(see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47648). So this needs to be added in
android-ndk-r8c/build/tools/build-gcc.sh
and
android-ndk-r8c/build/tools/build-host-gcc.sh
*) The error message "error: Pthreads are required to build libatomic"
Happens when building the ARM version of gcc-4.8 downloaded from gnu.org,
better stay with Google's GCCs.
*) The GCC that came with android-ndk-r8c didn't work for me (error message about
libstdc++.so.6 being too old), while the one in android-ndk-r8b worked
without problems. Since the android-ndk should support as many environments
as possible, I'm not sure why the Googlers decided to depend on a newer libstdc++,
but the good news are that building your own toolchain solves the issue.
*) If you get an error while compiling generic-morestack.c, then replace
#ifdef linux
// On Linux, the first two real time signals are used by the NPTL
with
#if defined(GLIBC) && defined(linux)
// On Linux, the first two real time signals are used by the NPTL
This starts off as an Android question but I think becomes a linux/cygwin question.
The Android ndk is shipped with an unsuitable version of awk - definitive report here - so I'm trying to get cygwin to accept that I don't want to use the ndk awk, but to use nawk or gawk instead.
Bearing in mind I know nothing about linux/cygwin, these are my discoveries:
The first part of the question has already been answered here so I know I need to rename the existing awk as awk_ so it isn't picked up (done). And I need to set the cygwin environment variable HOST_AWk to gawk (or nawk - both of which are supplied with cygwin). The easy way to do this (for me) is to set that environment variable in Windows - then when cygwin runs it imports all the environment stuff from Windows.
So I think I know what to do, but the value of HOST_AWK doesn't seem to be picked up when I try to do a build either directly in eclipse (build all) or in cygwin from bash:
Barry#BARRY /cygdrive/c/data/eclipse/camfeeda/jni
$ ndk-build
make: awk: Command not found
Android NDK: Host 'awk' tool is outdated. Please define HOST_AWK to point to Gawk or Nawk !
/cygdrive/c/DATA/eclipse/android/android-ndk-r7/build/core/init.mk:258: *** Android NDK: Aborting. . Stop.
Barry#BARRY /cygdrive/c/data/eclipse/camfeeda/jni
$ printenv HOST_AWK
c:\cygwin\bin\gawk.exe
As you see I have set HOST_AWK to gawk.exe in the correct location, but I've tried:
HOST_AWK=c:\cygwin\bin\gawk.exe
HOST_AWK=c:\cygwin\bin\gawk
HOST_AWK=c:\cygwin\bin\nawk.exe
HOST_AWK=c:\cygwin\bin\nawk
And I've tried using forward slashes in case that was the problem, but I still get the same error :(
I feel as if I am so close, but I can't make the last step. Why won't ndk-build read the environment variable HOST_AWK and do the dratted job?! Can anyone put me out of my misery?
Many thanks
Barry
Edit: I also tried:
HOST_AWK=/cygdrive/c/cygwin/bin/gawk.exe
etc, but no joy.
B.
For me it's just deleting/renaming awk.exe that is shipped with ndk-r7. And they everything works. No need for setting HOST_AWK env variable.
I would like to use cURL library in my android application in native code (using NDK r5b, the latest). After researching online, it seems the only way to use cURL in android is to build the entire android source tree with curl in it, and somehow this generates a necessary config file for cURL to work on Android. I don't have any experience building the android sources from scratch and was wondering if there is a way to use cURL library in Android without having to rebuild android from source. Ideally, being able to just use cURL as a static or shared library would be perfect. I tried following the steps mentioned here...
http://curl.haxx.se/mail/lib-2009-12/0071.html
but end up getting errors in the file curlrules.h like CURL_SIZEOF_LONG definition is missing!
I assume these errors are due to not having that config file I mentioned but the steps in the above link didn't mention any of that and reported success. Any ideas?
I'm on a similar quest! I'm working on an app right now that requires cURL and just tonight in my search I came across your post here, and what I believe to be the answer:
http://thesoftwarerogue.blogspot.com/2010/05/porting-of-libcurl-to-android-os-using.html
Unlike the link you referenced, there are several follow-up comments from other people who claim to have success also following the instructions. If you manage to get it compiled before me, and wouldn't mind sending me the library, post a follow up here! (I'm pretty new to stack overflow so I don't know if you can pm.) Hope this works out for both of us!
It seems that there are projects on github that automated both openssl and libcurl for NDK build:
https://github.com/jahrome/curl-android
https://github.com/guardianproject/openssl-android
Going to use those in my own app, so I can have single library to deal with backend communication for both iOS and Android...
After check all possibles post about this, I finally got a good compilation using a Linux x64 machine and Curl version 7.37.0 at path ${android-ndk-r10}.
Maybe this steps can help you:
1º
${android-ndk-r10}/build/tools/make-standalone-toolchain.sh --platform=android-15 --arch=armv7-a --toolchain=arm-linux-androideabi-4.8 --install-dir=./tmp/android-15
2º
export CC="${android-ndk-r10}/external/curl/tmp/android-15/bin/arm-linux-androideabi-gcc"
3º
./configure --host=arm-linux --enable-cross-compile --enable-threaded-resolver --disable-shared --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-manual --enable-proxy --enable-ipv6 --enable-cookies --enable-symbol-hiding --disable-versioned-symbols --disable-soname-bump --disable-sspi --disable-ntlm-wb --prefix=${android-ndk-r10}/external/curl/build/curl-7.37.0
4º
make -j4
5º
make install
You will get a build version at ${android-ndk-r10}/external/curl/build/curl-7.37.0.
If you are using a 64bits machine to compile, maybe 2 defines are bad, and you get this error:
error: size of array '__curl_rule_01__' is negative
I solve redefining the variables in file ${CurlbuildAndroid}/include/curl/curlbuild.h (Its dangerous to do this, but it worked!):
CURL_SIZEOF_LONG 4
CURL_TYPEOF_CURL_OFF_T 4
I followid this link. And it works for me. I did not have to download the whole android repository in order to compile the libcurl
You can choose to download cURL for android at https://play.google.com/store/apps/details?id=io.github.faywong.curl
"CURL_SIZEOF_LONG definition is missing!"
there is a way for it .
change the curlbuild.h at line number 162
add like this,if you are arm32 platform.
//----------------------------------------------add
# define CURL_SIZEOF_LONG 4
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_FORMAT_OFF_T "%lld"
# define CURL_SIZEOF_CURL_OFF_T 8
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
# define CURL_SIZEOF_CURL_SOCKLEN_T 4
//#define __SYMBIAN32__
I had a similar question which didn't get answered and thus was automatically removed :(
Anyway I've successfully used curl on android and have uploaded a compiled version to help the people still searching.
Download: libcurl_for_arm
I also required a typecheck-gcc.h file which I've amended and uploaded here too
Download: typecheck-gcc.h