Invalid character linking FFmpeg 3.4.2 built with NDK r16 - android

I'm in the process of updating my applications FFmpeg version from 2.8.6 to 3.4.2. I've managed to get FFmpeg built, but when I build my native library I'm getting a linker error:
/usr/local/android-sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/darwin-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: /shared/dev/libs/ffmpeg/3.4.2/lib/android-x86/libswresample.so:1:1: invalid character
/usr/local/android-sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/darwin-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: /shared/dev/libs/ffmpeg/3.4.2/lib/android-x86/libavcodec.so:1:1: invalid character
/usr/local/android-sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/darwin-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: /shared/dev/libs/ffmpeg/3.4.2/lib/android-x86/libavfilter.so:1:1: invalid character
/usr/local/android-sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/darwin-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: /shared/dev/libs/ffmpeg/3.4.2/lib/android-x86/libavutil.so:1:1: invalid character
The libraries are correct, but I don't understand where the :1:1: is coming from (assuming the trailing : is probably a delineator between the command and the error message). The path to the library is correct, but the filename definitely does not have a :1:1 in it.
I'm building on a Mac, so the first thing I do is:
sed -i ".orig" "s/SHFLAGS='-shared -Wl,-soname,\$(SLIBNAME)'/SHFLAGS='-shared -Wl,-install_name,\$(SLIBNAME)'/g" configure
so that ld uses the -install_name flag, rather than -soname. I used to have to do some other configure manipulation to strip the library naming out, but that doesn't seem to be necessary anymore (even if I do it I still get the same error).
FFmpeg was built using the following options:
./configure --prefix=output --enable-shared --disable-everything
--disable-iconv --disable-zlib --disable-bzlib
--enable-encoder=aac --enable-decoder=aac --enable-encoder=pcm_alaw
--enable-decoder=pcm_alaw --enable-encoder=pcm_mulaw
--enable-decoder=pcm_mulaw --enable-encoder=adpcm_g726
--enable-decoder=adpcm_g726 --enable-encoder=adpcm_ima_wav
--enable-decoder=adpcm_ima_wav --enable-encoder=mjpeg
--enable-decoder=mjpeg --enable-encoder=wmav1
--enable-decoder=wmav1 --enable-encoder=wmav2
--enable-decoder=wmav2 --enable-encoder=wmv1 --enable-decoder=wmv1
--enable-encoder=wmv2 --enable-decoder=wmv2
--enable-encoder=h264_vaapi --enable-encoder=hevc_vaapi
--enable-encoder=h264_nvenc --enable-encoder=hevc_nvenc
--enable-encoder=h264_omx --enable-encoder=h264_qsv
--enable-encoder=hevc_qsv --enable-decoder=aac_fixed
--enable-decoder=aac_latm --enable-decoder=adpcm_g726le
--enable-decoder=h263 --enable-decoder=h264 --enable-decoder=hevc
--enable-decoder=mjpegb --enable-decoder=mpeg4
--enable-decoder=h264_qsv --enable-decoder=h264_vdpau
--enable-decoder=hevc_qsv --enable-decoder=hevc_qsv
--enable-filter=scale --enable-filter=scale_vaapi
--enable-filter=scale_cuda --enable-filter=scale_npp
--enable-filter=scale_qsv --enable-parser=aac --enable-parser=h263
--enable-parser=h264 --enable-parser=hevc --enable-parser=mjpeg
--enable-muxer=asf --enable-demuxer=asf --enable-muxer=avi
--enable-demuxer=avi --enable-muxer=h263 --enable-demuxer=h263
--enable-muxer=h264 --enable-demuxer=h264 --enable-muxer=hevc
--enable-demuxer=hevc --enable-muxer=mjpeg --enable-demuxer=mjpeg
--enable-muxer=pcm_alaw --enable-demuxer=pcm_alaw
--enable-muxer=pcm_mulaw --enable-demuxer=pcm_mulaw --enable-muxer=wav
--enable-demuxer=wav --enable-demuxer=aac --enable-hwaccel=h264_d3d11va
--enable-hwaccel=hevc_d3d11va --enable-hwaccel=h264_d3d11va2
--enable-hwaccel=hevc_d3d11va2 --enable-hwaccel=h264_dxva2
--enable-hwaccel=hevc_dxva2 --enable-hwaccel=h264_vaapi
--enable-hwaccel=hevc_vaapi --enable-hwaccel=h264_vdpau
--enable-hwaccel=hevc_vdpau --enable-hwaccel=h264_nvenc
--enable-hwaccel=hevc_nvenc --enable-hwaccel=h264_qsv
--enable-hwaccel=hevc_qsv --enable-hwaccel=h264_vdpau
--enable-hwaccel=hevc_vdpau --disable-programs --enable-cross-compile
--cross-prefix=/shared/dev/toolchain/android/darwin-x86_64/ndk-r16/android-19/arm/bin/arm-linux-androideabi-
--arch=arm --target-os=android --disable-asm --disable-stripping
--disable-static --cc=clang --enable-pic
NDK toolchain is a standalone x86 toolchain built using NDK r16's make_standalone_toolchain.py tool.
The native project is built using CMake and using the clang android toolchain.
I've also got an arm version that gives the same linker error.
I'm not sure where exactly to start looking. Did this come from the build config options? I had to do quite a bit of tweaking to get it to build using NDK r16, but it was mostly stuff like adding --disable-stripping and changing --target-os from linux to android. Is it something with the NDK r16 toolchain?
Does anyone have any idea what the problem might be, or where I might start looking?

Ok, I figured this out.
It turns out that passing --cc=clang will configure the makefiles to use the system clang, not the clang available in the provided --cross-prefix. This was resulting in a binary built for the Darwin-x86_64 architecture, and NOT the Android x86 or Android ARM architectures.
Fix was to pass the complete path to the clang compiler with the --cc configure option.
I've made my build script available on GitHub for anyone else having trouble building FFmpeg for Android using NDK r16b:
android-ffmpeg-buildscript

Related

How to change Install Dir when Building OpenCV 3.1.0 on Ubuntu 18.04 for Android NDK18rc and ARMEABI-7?

I am trying for over one week to compile OpenCV 3.1.0 for Android with NDK r18 on Ubuntu 18.04.
I have used the following command:
cmake -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DANDROID_NDK="/home/qamaruddin/Downloads/android-ndk-r18-linux-x86_64/android-ndk-r18/" \
-DCMAKE_TOOLCHAIN_FILE="/home/qamaruddin/Downloads/android-ndk-r18-linux-x86_64/android-ndk-r18/build/cmake/android.toolchain.cmake" \
-DANDROID_NATIVE_API_LEVEL=19 \
-DANDROID_ABI="armeabi-v7a" \
-DWITH_CUDA=OFF \
-DWITH_MATLAB=OFF \
-DBUILD_ANDROID_EXAMPLES=OFF \
-DBUILD_DOCS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_TESTS=OFF \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DOPENCV_EXTRA_MODULES_PATH="/opt/opencv_contrib/modules/" \
-DCMAKE_INSTALL_PREFIX:PATH="/home/mig-ocv/ocv-android-310/" \
-DEXECUTABLE_OUTPUT_PATH:PATH="/home/mig-ocv/ocv-android-310/" \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH="/home/mig-ocv/ocv-android-310/" \
-DCMAKE_BUILD_TYPE=Release \
/opt/opencv
Follwed by make & make install/strip.
I have tried different versions of OpenCV 3 such as 3.1.0, 3.4.3, and 3.4.0. I have also tried NDKr15c, NDKr17c, and NDKr18c.
I have tried the following variations:
Change NDK version
Change OpenCV 3 version
Install using python script located at opencv/platforms/androind/setup.py
Build using CMAKE
Use Ninja for CMAKE, but this gives the error: "ninja: error: loading 'build/build.global.ninja': No such file or directory"
Install without Ninja with CMAKE
At the moment, using the above-posted command for CMAKE builds successfully, but I can't change the target install dir since it always builds into /usr/local/ and when I inspect the target directory it does not have the familiar OpenCV for Android structure which is:
1- etc
2- java
3- native --> jni --> include
I wonder what is wrong in my process that makes it so difficult to build OpenCV 3 from source for Android with OpenCV Contrib.
Note that $ANDROID_HOME is set to the android SDKs directory on my system and $ANDROID_NDK is also set.
I have seen all duplicate questions on StackOverflow and other forums, but none seems to work in my case.
When I try to build with Ninja with this command:
cmake -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DANDROID_NDK="$HOME/Downloads/android-ndk-r17b/" \
-DCMAKE_TOOLCHAIN_FILE="$HOME/Downloads/android-ndk-r17b/build/cmake/android.toolchain.cmake" \
-DANDROID_NATIVE_API_LEVEL=21 \
-DANDROID_ABI="armeabi-v7a" \
-DWITH_CUDA=OFF \
-DWITH_MATLAB=OFF \
-DBUILD_ANDROID_EXAMPLES=OFF \
-DBUILD_DOCS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_TESTS=OFF \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DOPENCV_EXTRA_MODULES_PATH="$HOME/ocv/opencv_contrib/modules/" \
-DCMAKE_INSTALL_PREFIX:PATH="$HOME/agusta/ocv-android-310/" \
-DEXECUTABLE_OUTPUT_PATH:PATH="$HOME/agusta/ocv-android-310/" \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH="$HOME/agusta/ocv-android-310/" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_MAKE_PROGRAM=/usr/bin/ninja \
$HOME/ocv/opencv
I get:
CMake Deprecation Warning at CMakeLists.txt:72 (cmake_policy):
The OLD behavior for policy CMP0022 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
CMake Deprecation Warning at CMakeLists.txt:77 (cmake_policy):
The OLD behavior for policy CMP0026 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
CMake Deprecation Warning at CMakeLists.txt:82 (cmake_policy):
The OLD behavior for policy CMP0042 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
-- Check for working CXX compiler: /home/qamaruddin/Downloads/android-ndk-r17b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
CMake Error: Generator: execution of make failed. Make command was: "/usr/bin/ninja" "cmTC_c4cee/fast"
-- Check for working CXX compiler: /home/qamaruddin/Downloads/android-ndk-r17b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- broken
CMake Error at /usr/local/share/cmake-3.12/Modules/CMakeTestCXXCompiler.cmake:45 (message):
The C++ compiler
"/home/qamaruddin/Downloads/android-ndk-r17b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/qamaruddin/agusta/temp/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/ninja" "cmTC_c4cee/fast"
No such file or directory
Generator: execution of make failed. Make command was: "/usr/bin/ninja" "cmTC_c4cee/fast"
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:93 (project)
-- Configuring incomplete, errors occurred!
See also "/home/qamaruddin/agusta/temp/CMakeFiles/CMakeOutput.log".
See also "/home/qamaruddin/agusta/temp/CMakeFiles/CMakeError.log".
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_CXX_COMPILER= /usr/bin/clang++
CMAKE_C_COMPILER= /usr/bin/clang
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
BUILD_ANDROID_EXAMPLES
BUILD_DOCS
BUILD_PERF_TESTS
BUILD_TESTS
EXECUTABLE_OUTPUT_PATH
OPENCV_EXTRA_MODULES_PATH
WITH_CUDA
WITH_MATLAB
-- Build files have been written to: /home/qamaruddin/agusta/temp
I have managed to get it to work, basically, OCV didn't support NDKr18, and I also had to install ninja from source. I have also used python3 instead of python2 to run the opencv/platforms/android/build_sdk.py . One more thing is that I use Eclipse Android ADT which Google has for no reason deprecated ;(, but I find it super fast compared to the heavy Android Studio.
# export ANDROID_ABI=armeabi-v7a
# export ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8
# export ANDROID_NDK=$HOME/Downloads/android-ndk-r17c-linux-x86_64/android-ndk-r17c/
# export ANDROID_SDK=$HOME/android-sdks/
./../opencv/platforms/android/build_sdk.py --extra_modules_path=/opt/opencv_contrib/modules --config ../opencv/platforms/android/ndk-17.config.py

Compiling gentoo-bionic on a x86_64 linux machine

As you may know, Bionic is a C library used by Google to run Android applications. There are efforts to compile it in Linux machines, so it could be easily used outside Android. This is the code from one the latest efforts, originally called Gentoo-bionic. The original project was Gentoo-based, but the current source is not Gentoo-specific. I am using Ubuntu. Here's the code:
https://github.com/gentoobionic/bionic
And this is the presentation about it on ELC2013:
http://elinux.org/images/2/25/2013_elc_gentoo_bionic.pdf
http://free-electrons.com/blog/elc-2013-videos/ (bad sound)
I tried to compile it on X86_64 Ubuntu, but failed. I tried:
./autogen.sh
./configure
I got:
configure: error: unsupported host cpu x86_64
So I tried:
./configure --build=arm-linux --target=arm-linux --host=arm-linux
It configured fine, but I got:
$ make
make: *** No rule to make target `libc/arch-x86/include/machine/cpu-features.h',
needed by `all-am'. Stop.
Is there a chance that someone can suggest a workaround?
I dont know anything about bionic. I just want to help you.
when i viewed configure file, i saw this code.
Makefile.h.am:Line 135
if TARGET_ARCH_IS_X86
includemachine_HEADERS += \
$(addprefix $(top_srcdir)/libc/arch-x86/include/, \
machine/fpu_control.h \
machine/sigcontext.h \
machine/wordsize.h \
)
endif
if TARGET_ARCH_IS_ARM
includemachine_HEADERS += \
$(addprefix $(top_srcdir)/libc/arch-x86/include/, \
machine/cpu-features.h \
)
endif
configure.ac: Line 94
case $host_cpu in
*i?86*)
TARGET_ARCH=x86
COMMON_LDFLAGS="${COMMON_LDFLAGS} ${COMMON_LDFLAGS_X86}"
COMMON_CFLAGS="${COMMON_CFLAGS} ${COMMON_CFLAGS_X86}"
COMMON_INCLUDES="${COMMON_INCLUDES} ${COMMON_INCLUDES_X86}"
COMMON_LDLIBS="${COMMON_LDLIBS} ${COMMON_LDLIBS_X86}"
;;
*arm*)
TARGET_ARCH=arm
COMMON_LDFLAGS="${COMMON_LDFLAGS} ${COMMON_LDFLAGS_ARM}"
COMMON_CFLAGS="${COMMON_CFLAGS} ${COMMON_CFLAGS_ARM}"
COMMON_INCLUDES="${COMMON_INCLUDES} ${COMMON_INCLUDES_ARM}"
COMMON_LDLIBS="${COMMON_LDLIBS} ${COMMON_LDLIBS_ARM}"
;;
*)
AC_MSG_ERROR([unsupported host cpu $host_cpu])
;;
esac
There is no cpu-features.h file on include/machine folder. So, you have to use different target.
Since Nov 2015 my set of ebuid scripts compile bionic for x86_64 and i386 on my Gentoo x86_64 desktop. Tools required: glibc-targeting GCC version 4.9.3 or 5.3.0; binutils 2.4.25 or older, glibc-targeting clang 3.5.0, make.
If you can install those tools on your desktop, you can potentially compile bionic.
Note however that my ebuilds apply zillion of patches.
To see what they do, you can the following:
Boot live Gentoo DVD on a x86_64 desktop or notebook.
Install my scripts.
Run them capturing output, for instance
USE=verbose ebuild bionic/bionic-5.1.1-r29.ebuild clean install qmerge 2>&1 | tee /tmp/bionic.cout
Once such command terminates, you get the patched source tree, intermediate and final compilation result, and full build log with gcc/clang/ld/ar command-lines.

Compile x264 with Thread Support for Android Platform

I've been tryin' to compile x264 for Android with Thread Support...But with no success...
I've managed to compile the same without thread support...The configure command is as follows :
./configure --prefix=$PREFIX \
--enable-pic \
--host=arm-linux \
--disable-cli \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--sysroot=$PLATFORM
where PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86 and
PLATFORM=$NDK/platforms/android-14/arch-arm
I've also tried with and without the option --enable-static and extra-ldflags="-lpthread", but when attempted make it ends with errors.
Is there any way to accomplish the above said...?
The error that seemed to appear in config.log in context to thread support was cannot find lpthread...
That got resolved by manually removing the -lpthread from the configure file.
But then the configuration started failing at the test that included the struct cpu_set_t and CPU_COUNT()...
Seems that certain libc functions and definitions are not included in the code provided with Android NDK (R8D)...In the above case CPU_COUNT() and the definition for struct cpu_set_t...
The workaround for the above was to patch sched.h with the latest version...
There are a few bug reports in the Android Issue List describing the same problem which would hopefully be addressed in the next NDK release...
Also x264 could be compiled to include the " ARM Support Feature " by including the option --extra-cflags="-mfloat-abi=softfp"...

How can I get JHC to cooperate with the android ndk?

JHC is a Haskell compiler which portable generates C code and then invokes a compiler backend to make an executable.
I need to dump the header files and libraries for JHC's runtime system, so the android ndk can use it to compile the generated C code.
Alternatively, I need to figure out how to link the android API into JHC.
Basically, how can I plug JHC into the android ndk backend?
Edit: I've made a standalone compiler using one of the ndk's build tools that JHC can use, "build/tools/make-standalone-toolchain.sh" . Now I need to figure out a way for JHC to compile my program into a shared object library, and how to get JHC to not demand a "main" function.
Edit2: I have the following targets.ini and compile script. Strangely the shared library fails to load.
[android]
cc=arm-linux-androideabi-gcc
cflags+= -shared -fPIC -rdynamic -Wno-all
gc=static
executable_extension=.so
merge=mle32
and
#!/bin/sh
jhc --cross -mandroid \
--main=Main.android_main \
hs/Main.hs -o libs/armeabi/libnative-activity &&
ant debug &&
ant debug install
I figured out the problem.
I didn't put the function call "app_dummy()" at the start of my "android_main" function.

How to configure gcc to compile for android?

I've read in the gcc documentation that it supports building android binaries with the -mandroid and -mbionic switches. First I tried it with the native gcc built from svn. Result:
dancsi#dancsi-VirtualBox:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.7.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../source/configure --enable-threads --disable-nls
Thread model: posix
gcc version 4.7.0 20110611 (experimental) (GCC)
dancsi#dancsi-VirtualBox:~$ g++ test.cpp -mandroid -o test.out
dancsi#dancsi-VirtualBox:~$ file test.out
test.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
Basically, it failed. Next, I tried to compile the same gcc sources with target=arm-linux-androideabi, (without defining sysroot,...), and it passed the configuration, but failed to build saying pthread.h is not found:
In file included from ../.././gcc/gthr-default.h:1:0,
from ../../../combined/libgcc/../gcc/gthr.h:160,
from ../../../combined/libgcc/../gcc/unwind-dw2.c:37:
../../../combined/libgcc/../gcc/gthr-posix.h:41:21: fatal error: pthread.h: No such file or directory
compilation terminated.
So, does anybody have the instructions for how to use gcc to build android binaries (I don't want to use code sourcery or android-ndk)?
EDIT:
my configure options
configure --target=arm-linux-android --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-libssp --disable-libgomp --disable-nls --enable-languages=c,c++,java
I had exactly the same problem as described by dancsi while trying to compile my own cross compilation tool chains for Android (I wanted to build a 32 bit variant of them so I don't need to buy a 64 bit PC or do my android stuff in a VM).
I am using the tool chain sources from the official AOSP tool chain repo:
repo init -u https://android.googlesource.com/toolchain/manifest
The solution is to use the following 2 extra configure options: --with-headers and --with-libs. I've got this solution by reading the following file: [android-toolchain-repo]/build/README:
The other way is to specify the headers and libraries with --with-headers and
--with-libs separately. If you configure your tree with a prefix. The headers
and libraries will be copied to the install directory specified by the prefix.
For the values of those 2 extra parameters I used [android-src-repo]/prebuilts/ndk/8/platforms/android-14/arch-arm/usr/lib and [android-src-repo]/prebuilts/ndk/8/platforms/android-14/arch-arm/usr/include. [android-src-repo] is referring to my repo checkout of the base AOSP sources (in my case I am on the android-4.2.2_r1 branch of it).
The end-result of the two configure statements I need are the following:
./configure --target=arm-eabi --host=i686-linux-gnu --build=i686-linux-gnu --disable-gold \
--with-gcc-version=4.6 --with-binutils-version=2.21 --with-gmp-version=4.2.4 --with-mpfr-version=2.4.1 \
--with-gdb-version=7.3.x --with-gold-version=2.21 --prefix=/tmp/toolchain --disable-multilib \
--with-libs=/home/boeboe/android-src/prebuilts/ndk/8/platforms/android-14/arch-arm/usr/lib \
--with-headers=/home/boeboe/android-src/prebuilts/ndk/8/platforms/android-14/arch-arm/usr/include \
--program-transform-name='s&^&arm-eabi-&' --with-arch=armv5te --disable-option-checking
./configure --target=arm-linux-androideabi --host=i686-linux-gnu --build=i686-linux-gnu --enable-gold \
--with-gcc-version=4.6 --with-binutils-version=2.21 --with-gmp-version=4.2.4 --with-mpfr-version=2.4.1 \
--with-gdb-version=7.3.x --with-gold-version=2.21 --prefix=/tmp/toolchain \
--with-libs=/home/boeboe/android-src/prebuilts/ndk/8/platforms/android-14/arch-arm/usr/lib \
--with-headers=/home/boeboe/android-src/prebuilts/ndk/8/platforms/android-14/arch-arm/usr/include \
--program-transform-name='s&^&arm-linux-androideabi-&' --disable-option-checking
Notice the extra --disable-option-checking argument which was necessary for configure to accept all arguments!
This long list of arguments was constructed by checking the original configure arguments passed for the default 64 bit version of the 4.6 gcc toolchain. This can be checked in the SOURCES files available in [android-src-repo]/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6 and [android-src-repo]/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6.
In the same files, git tags can be found, so I also checkout those specific version in my [android-toolchain-repo]. For the extra modules needed by gcc, like gmp/mpfr/gdb..., I extracted the correct versions of the tar-balls available in [android-toolchain-repo]/gmp|mpfr|gdb. This was the easiest way I could find out, for my original configure statement to be able to pick up those modules.
The same technique as described above also allowed me to compile a 32 bit variant of the latest gcc 4.7 tool chain (currently being used on the MAIN branch of AOSP). The configure options were of course different in this case.
In file included from ../.././gcc/gthr-default.h:1:0,
from /mnt/network/source/gcc/libgcc/../gcc/gthr.h:160,
from /mnt/network/source/gcc/libgcc/../gcc/unwind-dw2.c:37:
/mnt/network/source/gcc/libgcc/../gcc/gthr-posix.h:41:21: fatal error: pthread.h: No such file or directory
compilation terminated.
make[2]: *** [unwind-dw2.o] Error 1
make[1]: *** [all-target-libgcc] Error 2
make: *** [all] Error 2
I'm getting the same error as you, but I'm not compiling for Android. I'm trying to build w64-mingw32 compiler.
AR=x86_64-w64-mingw32-ar RANLIB=x86_64-w64-mingw32-ranlib
../gcc-4.5.1/configure --prefix=/tools \
--with-local-prefix=/tools --enable-clocale=gnu \
--enable-shared --enable-threads=posix \
--enable-__cxa_atexit --enable-languages=c,c++ \
--disable-libstdcxx-pch --disable-multilib \
--disable-bootstrap --disable-libgomp \
--without-ppl --without-cloog --build=$MACHTYPE --host=$MACHTYPE --target=x86_64-w64-mingw32
My response is so you know its not just Android, the trouble is more general then just building for the ARM architecture.
I think its a c++ issue, cause I had/have no trouble with building a c compiler alone.

Categories

Resources