Cross-compiling a MPICH library for Android NDK - android

My goal is to run MPICH on Android phones. I'm using Debian Jessie. I thought that I'll achieve that following this tutorial:
http://hex.ro/wp/projects/personal-cloud-computing/compiling-mpich2-for-android-and-running-on-two-phones/
but instead of creating toolchain with Buildroot I decided to create it from Android NDK, as on this site:
http://www.threadstates.com/articles/2013/setting-up-an-android-cross-compiling-environment-with-the-ndk.html
I tried to use MPICH library versions 2.1.4, 2.1.5, 3.0.4 and configure it using command:
sudo CFLAGS=" -march=armv5 -mfpu=vfp -static "
CC=/home/cerbia/android/bin/arm-linux-androideabi-gcc ./configure
--prefix=/home/cerbia/old --host=arm-linux --with-pm=smpd --disable-f77 --disable-fc
but I still had this kind of error:
configure: error: SMPD requires MD5 support, and configure could not
find either md5_calc in md5.h or MD5 in openssl/md5.h
I found, that it is connected with openssl version and I tried to follow this instruction:
Download, compile, modify and install OpenSSL to the NDK directory. cd ~ wget www.openssl.org/source/openssl-1.0.0g.tar.gz tar xvzf
openssl-1.0.0g.tar.gz cd openssl-1.0.0g ./config no-asm shared --prefix=$ANDROID_ROOT/platforms/android-3/arch-arm/usr
edit Makefile:
CC= arm-linux-gnueabi-gcc-4.6
CFLAG= -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DOPENSSL_N -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -fPIC
DEPFLAG= -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_R C5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_STORE
PEX_LIBS=
EX_LIBS= -ldl
EXE_EXT=
ARFLAGS=
AR= arm-linux-gnueabi-ar $(ARFLAGS) r
RANLIB= arm-linux-gnueabi-ranlib
NM= arm-linux-gnueabi-nm
PERL= /usr/bin/perl
TAR= tar
TARFLAGS= --no-recursion
MAKEDEPPROG= gcc
LIBDIR=lib
Than instead of HIPL I tried to cross-compile MPICH in the analogous way as below
Download and cross-compile HIPL. cd ~ bzr co lp:hipl trunk cd trunk edit configure.ac and comment out all AM_CFLAGS autoreconf --install
./configure --disable-gcc-warn --disable-firewall -host=arm-linux
CC=arm-linux-gnueabi-gcc-4.6
CPPFLAGS="-I$ANDROID_ROOT/platforms/android-3/arch-arm/usr/include"
CFLAGS="-nostdlib"
LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/platforms/android-3/arch-arm/usr/lib,-L$ANDROID_ROOT/platforms/android-3/arch-arm/usr/lib"
LIBS="-lc" make make all-am make[1]: Entering directory `/home/mkomu/projects/hipl-bzr/arm' CC lib/core/builder.lo In file
included from lib/core/debug.h:34:0,
from lib/core/crypto.h:43,
from lib/core/builder.c:100: lib/core/protodefs.h:917:5: error: unknown type name 'in_port_t'
lib/core/protodefs.h:929:5: error: unknown type name 'in_port_t'
lib/core/protodefs.h:1027:5: error: unknown type name 'in_port_t'
lib/core/protodefs.h:1036:5: error: unknown type name 'in_port_t'
lib/core/protodefs.h:1043:5: error: unknown type name 'in_port_t'
lib/core/protodefs.h:1054:5: error: unknown type name 'in_port_t'
lib/core/protodefs.h:1055:5: error: unknown type name 'in_port_t' ...
it comes from site: bugs.launchpad.net/hipl/+bug/715126
but I got the same errors as person there..
make[8]: Wejście do katalogu
`/home/cerbia/old/mpich2-1.3.2/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp'
CC tcp_finalize.c In file included from
tcp_finalize.c:7:0: tcp_impl.h:108:89: error: unknown type name
'in_port_t' make[8]: * [tcp_finalize.o] Błąd 1
Do you have any advices what I should try to make it working?

In Linux, in_port_t is typedefed as uint16_t in netinet/in.h. The only place this typedef is used is in the definition of sockaddr_in.
The Android NDK does not define or use in_port_t, but instead uses unsigned short int. To compile code using the Android NDK, either typedef in_port_t or replace it with unsigned short int.

Related

How to build boost for android as shared library with c++11 support

I am trying to build boost_1.60.0 (as shared library) for android with c++11 support. I am using the latest ndk (currently android-ndk-r10e). The build host is Windows-10.
This is for a non-opensource project. So as far as I understand I cannot use gnustl_shared, and I need to use c++_shared as the android c++ runtime.
my project-config.jam looks like this:
androidNDKRoot = c:/android-ndk-r10e ;
using gcc : android :
$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ :
<root>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/
<compileflags>-MMD
<compileflags>-MP
<compileflags>-MF
<compileflags>-fpic
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector
<compileflags>-no-canonical-prefixes
<compileflags>-march=armv5te
<compileflags>-mtune=xscale
<compileflags>-msoft-float
<compileflags>-fno-rtti
<compileflags>-mthumb
<compileflags>-Os
<compileflags>-g
<compileflags>-DNDEBUG
<compileflags>-fomit-frame-pointer
<compileflags>-fno-strict-aliasing
<compileflags>-finline-limit=64
<compileflags>-IC:/android-ndk-r10e/sources/cxx-stl/llvm-libc++/libcxx/include
<compileflags>-IC:/android-ndk-r10e/sources/cxx-stl/llvm-libc++/../llvm-libc++abi/libcxxabi/include
<compileflags>-IC:/android-ndk-r10e/sources/cxx-stl/llvm-libc++/../../android/support/include
<compileflags>-IC:/android-ndk-r10e/platforms/android-9/arch-arm/usr/include
<compileflags>-Wa,--noexecstack
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-DUNIX
<compileflags>-DANDROID
<compileflags>-Wl,--no-undefined
<cxxflags>-fexceptions
<linkflags>-lc++_shared
<archiver>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ar
<ranlib>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ranlib
;
the build command is:
b2 --toolset=gcc-android cxxflags="-std=c++11 " --prefix=..\boost_android_arm --builddir=./boost_android_arm/builddir target-os=linux --with-filesystem define=BOOST_FILESYSTEM_VERSION=3 link=shared runtime-link=shared threading=multi
In order to determine the parameters in the project-config.jam I've build a sample shared library using the ndk-build, get its debug messages, and extracted the compile and link commands it uses.
compile:
C:\android-ndk-r10e\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin\arm-linux-androideabi-g++.exe,C:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi/objs/someLib/./Unity1.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Ijni/../../library/../../../../ -Ijni/../../library/../../../../src/ -IC:/android-ndk-r10e/sources/cxx-stl/llvm-libc++/libcxx/include -IC:/android-ndk-r10e/sources/cxx-stl/llvm-libc++/../llvm-libc++abi/libcxxabi/include -IC:/android-ndk-r10e/sources/cxx-stl/llvm-libc++/../../android/support/include -Ijni/../../library -DANDROID -DHAVE_CONFIG_H -DSESTEK_ANDROID_XERCES_HACK -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -fno-strict-aliasing -frtti -fexceptions -DUNIX -DANDROID -IC:/android-ndk-r10e/platforms/android-9/arch-arm/usr/include -c jni/../../library/./Unity1.cpp -o ./obj/local/armeabi/objs/someLib/./Unity1.o,...)
link:
C:\android-ndk-r10e\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin\arm-linux-androideabi-g++.exe,C:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -Wl,-soname,libsomeLib.so -shared --sysroot=C:/android-ndk-r10e/platforms/android-9/arch-arm ./obj/local/armeabi/objs/someLib/./Unity1.o -lgcc ./obj/local/armeabi/libc++_shared.so -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -mthumb -lc -lm -o ./obj/local/armeabi/libsomeLib.so,...)
For brevity I've only build filesystem for this trial but in the end I plan to build at least thread, filesystem, date_time, asio and log libraries.
Finally the error I get is as follows.
...patience...
...found 660 targets...
...updating 13 targets...
gcc.compile.c++ bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\error_code.o
gcc.link.dll bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\libboost_system-gcc-mt-1_60.so.1.60.0
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot open crtbegin_so.o: No such file or directory
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lrt
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot open crtend_so.o: No such file or directory
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lc++_shared
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lstdc++
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lm
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lc
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -ldl
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lc
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\error_code.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\error_code.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\error_code.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
./boost/system/detail/error_code.ipp:458: error: undefined reference to '__dso_handle'
./boost/system/detail/error_code.ipp:464: error: undefined reference to '__dso_handle'
./boost/system/detail/error_code.ipp:158: error: undefined reference to '__dso_handle'
collect2.exe: error: ld returned 1 exit status
"c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++" -o "bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\libboost_system-gcc-mt-1_60.so.1.60.0" -shared -Wl,--start-group "bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\error_code.o" -Wl,-Bstatic -Wl,-Bdynamic -lrt -Wl,--end-group -lc++_shared -pthread
...failed gcc.link.dll bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\libboost_system-gcc-mt-1_60.so.1.60.0...
...skipped <pstage\lib>libboost_system-gcc-mt-1_60.so.1.60.0 for lack of <pbin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi>libboost_system-gcc-mt-1_60.so.1.60.0...
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\codecvt_error_category.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\operations.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\path.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\path_traits.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\portability.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\unique_path.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\utf8_codecvt_facet.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\windows_file_codecvt.o
...skipped <pbin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi>libboost_filesystem-gcc-mt-1_60.so.1.60.0 for lack of <pbin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi>libboost_system-gcc-mt-1_60.so.1.60.0...
...skipped <pstage\lib>libboost_filesystem-gcc-mt-1_60.so.1.60.0 for lack of <pbin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi>libboost_filesystem-gcc-mt-1_60.so.1.60.0...
...failed updating 1 target...
...skipped 3 targets...
...updated 9 targets...
The error tells that it needs the directory to find the necessary libraries, but the problem is that under android ndk there are several files with names rt and crtbegin_so.o and such. I guess I need to make the compiler determine the correct directory itself.
With all being said what I need actually is to build boost shared libraries for android with c++11 support. So I may accept your help either by pointing me in the right direction using the above build parameters or providing me a working sample so I can work out the details myself.
Oh also one more thing: if I use link=static instead of link=shared in the build command the build succeeds. But I have not tried the produced static libraries.
Building Boost on Linux using the NDK
I know you're asking about Windows, but I wanted to do this on macOS and it failed with nearly the exact error. I finally broke down and did it on my linode server it worked without a problem. This says to me that they aren't really doing a good job of testing other platforms. Compiling static only on macOS works as you also discovered on Windows.
Point of reference
NDK R13
Boost 1.62.0
Tested with clang++; g++ also works
If you're wondering why I'm using clang, the Release Notes have the following message:
GCC is no longer supported. It will not be removed from the NDK just
yet, but is no longer receiving backports. It cannot be removed until
after libc++ has become stable enough to be the default, as some parts
of gnustl are still incompatible with Clang. It will likely be removed
after that point.
user-config.jam
I placed this file in my home directory. Yuck.
androidNDKRoot = /path/to/ndk-R13-standalone ;
using clang : android
:
$(androidNDKRoot)/bin/arm-linux-androideabi-clang++
:
;
Modifying libtool.m4 in boost to avoid versioning of the libraries
libtool.m4 under tools/build/src/engine/boehm_gc/libtool.m4 in the boost source has no reference to android and you'll need to change version_type=linux in the section linux*) to version_type=none. This will cause symbolic links to appear without the version number appended to the end linked to the versioned shared libraries in the output.
Building
Target OS MUST be android to avoid the -lrt flag being passed which will cause shared linking to fail.
./b2 \
-d+2 \
-j 4 \
--reconfigure \
target-os=android \
toolset=clang-android \
include=${ANDROID_NDK_STANDALONE}/include/c++/4.9.x \
link=static,shared \
variant=debug,release \
threading=multi \
--layout=versioned \
--prefix=${BOOST_INSTALL_DIR} \
install
A relevant information is here (Boost for Android), where they have been able to successfully build the shared libraries, but it seems that the resulting files have a version suffix which android can't handle. Also one can't just rename the binary because the file name is hardcoded in it. One way out, as per the last post, is to set the variable version_type to none (version_type=none) in the linux section of file. In your case, the build setup could be a little different, but it may be worthwhile to take a look at the changes they made at that discussion.
user-config.jam
If you want to find boost from cmake(find_package) you must use the version of compiler, and not android like the top answer, in your user-config.jam like below according to boost doc.
androidNDKRoot = /path/to/ndk-R13-standalone ;
using clang : 8.0.1
:
$(androidNDKRoot)/bin/arm-linux-androideabi-clang++
:
;
My answer for me in future. How to build latest Boost(1.79.0) with latest NDK(24.0) on Windows PC for Android.
Go to your downloaded boost_1_79_0 unpacked directory and build b2 tool:
.\bootstrap.bat
Check b2 tools is ready:
b2 --version
B2 4.8-git <-- possible output
create file user-config.jam in %HOME% directory with content like that(example):
using clang : arm64 : c\:/Users/l_chayka/Downloads/android-ndk-r24/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android21-clang++.cmd : <cxxflags>-std=c++20 ;
using clang : arm : c\:/Users/l_chayka/Downloads/android-ndk-r24/toolchains/llvm/prebuilt/windows-x86_64/bin/armv7a-linux-androideabi21-clang++.cmd : <cxxflags>-std=c++20 ;
using clang : x86 : c\:/Users/l_chayka/Downloads/android-ndk-r24/toolchains/llvm/prebuilt/windows-x86_64/bin/i686-linux-android21-clang++.cmd : <cxxflags>-std=c++20 ;
using clang : x86_64 : c\:/Users/l_chayka/Downloads/android-ndk-r24/toolchains/llvm/prebuilt/windows-x86_64/bin/x86_64-linux-android21-clang++.cmd : <cxxflags>-std=c++20 ;
Go to boost root and try to build for every Android architecture (arm, arm64, x86, x86_64) example:
c:\Users\l_chayka\Downloads\boost_1_79_0>b2.exe toolset=clang-x86_64 target-os=android link=static variant=debug threading=multi --layout=versioned --prefix=c:/boost-x64_86/ install
c:\Users\l_chayka\Downloads\boost_1_79_0>b2.exe toolset=clang-x86 target-os=android link=static variant=debug threading=multi --layout=versioned --prefix=c:/boost-x86/ install
c:\Users\l_chayka\Downloads\boost_1_79_0>b2.exe toolset=clang-arm target-os=android link=static variant=debug threading=multi --layout=versioned --prefix=c:/boost-arm/ install
c:\Users\l_chayka\Downloads\boost_1_79_0>b2.exe toolset=clang-arm64 target-os=android link=static variant=debug threading=multi --layout=versioned --prefix=c:/boost-arm64/ install
Now check you instalation prefix path.

cross compiling using Android toolchains

I need to compile mpich for android , I used NDK arm-linux-andoirdeabi-4.8 toolchain to cross compile mpi , I did the following
export PATH="$NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/:$PATH"
export SYS_ROOT="$NDK_ROOT/platforms/android-8/arch-arm/"
export CC="arm-linux-androideabi-gcc --sysroot=$SYS_ROOT"
export LD="arm-linux-androideabi-ld"
export AR="arm-linux-androideabi-ar"
./configure --host=arm-linux-androideabi --prefix=/Crosscompile2/jni/mpich/ LIBS="-lc -lgcc " --disable-shared --disable-fortran --disable-cxx
but I got the following error:
checking for pthread_key_create in -lpthread... no
checking checkpointing library... configure: error: pthreads is required for checkpointing, but was not found
configure: error: src/pm/hydra configure failed
when I added -lpthread
LIBS="-lc -lgcc -lpthread"
it didn't compile
checking whether the C compiler works... no
configure: error: C compiler cannot create executables
Android is special in that it implements pthreads, but does not have a separate libpthread.a. The easy workaround is to add an empty library to your toolchain usr/lib
$AR q $SYS_ROOT/usr/lib/libpthread.a
before running ./configure
For the libpthread problems, you have 2 options.
sed out the requirement from the configure/makefiles since pthread is included in bionics libc
Or
Create a libpthead that's a symlink to libc
cd $SYSROOT/usr/lib
ln -s libc.a libpthread.a

Install valgrind for android, C compiler doesn't work

I'm trying to configure valgrind for android on Windows 7. I'm using guide from this site, but there is a problem with C compiler while configure. I'm using cygwin.
Error:
configure:3531: error: in /cygdrive/c/Tools/valgrind-3.9.0':
configure:3533: error: C compiler cannot create executables
Script:
#!/bin/bash
export NDKROOT=C:/Tools/AndroidNDK-r6
export HWKIND=generic # A generic Android device. eg, Pandaboard
export AR=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-ar.exe
export LD=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-ld.exe
export CC=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc.exe
CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm -DANDROID_HARDWARE_$HWKIND" \
CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" \
./configure --prefix=/data/local/Inst \
--host=armv7-unknown-linux --target=armv7-unknown-linux \
--with-tmpdir=/sdcard
make
make install
and config.log file
Obviously, there's a kind of a problem executing the compiler from within the NDK folder. The log file states:
configure:3422: checking for C compiler version
configure:3431: C:/Tools/AndroidNDK-r6
/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc.exe
--version >&5
./configure: line 3433: C:/Tools/AndroidNDK-r6
/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc.exe
: No such file or directory
So next you want to make sure that the path actually exists and the compiler executable is executable indeed. You can try yourself to type directly in cygwin shell:
C:/Tools/AndroidNDK-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc.exe -v
...and see what happens.

configure: error: C compiler cannot create executables when configuring for Android

I have downloaded the CPP Unit Test framework and trying to compile for the Android. But, facing the Configure issues. I tried making Standalone tool chain and also tried configuring but its always failing
sh-4.1$ ./configure CXX=arm-linux-androideabi-g++ CC=arm-linux-androideabi-gcc CPP=arm-linux-androideabi-g++ CXXCPP=arm-linux-androideabi-g++
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make sets $(MAKE)... (cached) yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... arm-linux-androideabi-gcc
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
sh-4.1$ arm-linux-androideabi-g++
arm-linux-androideabi-g++.exe: fatal error: no input files
compilation terminated.
sh-4.1$
My build environment is NDKr8, Cygwin, Windows7-x64.
I tried going through the config.log and found that the error is
arm-linux-androideabi-gcc.exe: error: CreateProcess: No such file or directory
I tried for fixing the above error by cutting down the path length and so on. But still not able to resolve. Please let me know if anyone has resolved similar problem.
Just to add the information from the link http://curl.haxx.se/mail/lib-2012-08/0184.html
but facing same issue with out Cygwin as well.
D:\Test>arm-linux-androideabi-gcc Main.c
arm-linux-androideabi-gcc: error: CreateProcess: No such file or directory
D:\Test>
As you observer even in the windows prompt as well it is the same issue.
----- Edit 1 -----
I tried configuring on the Ubuntu 12.04 OS with the below line
./configure --host=arm CXX=arm-linux-androideabi-g++ CC=arm-linux-androideabi-gcc CPP=arm-linux-androideabi-g++ CXXCPP=arm-linux-androideabi-g++
But getting these errors
checking how to run the C preprocessor... arm-linux-androideabi-g++
configure: error: in `/mnt/hgfs/VMShare/gperftools-2.0_Android/gperftools-2.0':
configure: error: C preprocessor "arm-linux-androideabi-g++" fails sanity check
See `config.log' for more details.
But most of the times ARM android Gcc compiler is failing.
configure:4216: arm-linux-androideabi-gcc -qversion >&5
arm-linux-androideabi-gcc: error: unrecognized option '-qversion'
arm-linux-androideabi-gcc: fatal error: no input files
Give the correct path and environment.
Example setup:
export NDK=/develop/android/android-ndk-r9b
export SYSROOT=$NDK/platforms/android-18/arch-x86
export CC="$NDK/toolchains/x86-4.7/prebuilt/linux-x86/bin/i686-linux-android-gcc --sysroot=$SYSROOT"
export CFLAGS="--sysroot=$SYSROOT "
export LDFLAGS="--sysroot=$SYSROOT "
I don't have experience with your particular setup, but when I was getting this error, I fixed it by adding gcc's bin folder to the system path and additionally, there had to be a version of each executable without a prefix (for example g++.exe, ld.exe...) in the gcc's bin directory. This solved the issue for me. I also logged off/on after changing the path, but don't know if it's necessary.
I got the idea here:
http://forums.codeblocks.org/index.php?topic=18100.0

Compiling ICU using arm-linux-androideabi-4.4.3

I would like to cross-compile ICU static libs for Android using Cygwin. So far, I have been able to configure and make the Cygwin/MSVC and Cygwin versions. I have installed the android-ndk-r7 and can see a version of gcc in the toolchains directory. Several examples suggest using host:arm-eabi - but this is not present on my machine.
I have copied mh-linux to mh-unknown in /icu/source/config and run the following:
export HOST_ICU=/cygdrive/d/__/External/SQLite/icu
export ICU_CROSS_BUILD=/cygdrive/d/__/External/SQLite/icu-cygwin
export NDK_ROOT=/cygdrive/d/__/android-ndk-r7
export CPPFLAGS="-I$NDK_ROOT/platforms/android-8/arch-arm/usr/include/ -O3 -fno-short-wchar -DU_USING_ICU_NAMESPACE=0 -DU_GNUC_UTF16_STRING=0 -fno-short-enums -nostdlib"
export CXXFLAGS="-I$NDK_ROOT/platforms/android-8/arch-arm/usr/include/ -O3 -fno-short-wchar -DU_USING_ICU_NAMESPACE=0 -DU_GNUC_UTF16_STRING=0 -fno-short-enums -nostdlib"
export CFLAGS="-I$NDK_ROOT/platforms/android-8/arch-arm/usr/include/ -O3 -fno-short-wchar -DU_USING_ICU_NAMESPACE=0 -DU_GNUC_UTF16_STRING=0 -fno-short-enums -nostdlib"
export LDFLAGS="-lc -Wl,-rpath-link=$NDK_ROOT/platforms/android-8/arch-arm/usr/lib/ -L $NDK_ROOT/platforms/android-8/arch-arm/usr/lib/"
$HOST_ICU/source/configure --with-cross-build=$ICU_CROSS_BUILD --enable-extras=no --enable-strict=no --enable-static --enable-shared=no --enable-tests=no --enable-samples=no --enable-dyload=no --enable-tools=no --host=arm-eabi --with-data-packaging=archive
I get the following error:
checking for ICU version numbers... release 4.8.1.1, library 48.1.1, unicode version 6.0
checking build system type... i686-pc-cygwin
checking host system type... arm-unknown-eabi
checking target system type... arm-unknown-eabi
checking whether to build debug libraries... no
checking whether to build release libraries... yes
checking for arm-eabi-gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/cygdrive/d/Projects/__/External/SQLite/icu-android':
configure: error: C compiler cannot create executables
See `config.log' for more details
I'm sure this is a "stupid" question, but how do I get the ICU configure script to point to the gcc under $NDK_ROOT\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\arm-linux-androideabi\bin? Am I missing some setup or install? Should I be setting my PATH so that the first gcc found is the one in arm-linux-androiedeabi?
Update 1. I just noticed that while windows\arm-linux=androideabi\bin contains gcc, windows\bin contains arm-linux-androideabi-gcc. How do I get ICU to call this?
Update 2. On the suggestion of Steven R. Loomis, I picked up updates for config.sub and config.guess from
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
placed android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin into my path, and re-ran configure with --host=arm-linux-androideabi... this time:
checking for arm-linux-androideabi-gcc... arm-linux-androideabi-gcc
checking whether the C compiler works... no
Definitely closer. Detailed error from config.log
gcc version 4.4.3 (GCC)
configure:3125: $? = 0
configure:3114: arm-linux-androideabi-gcc -V >&5
arm-linux-androideabi-gcc.exe: '-V' option must have argument
configure:3125: $? = 1
configure:3114: arm-linux-androideabi-gcc -qversion >&5
arm-linux-androideabi-gcc.exe: unrecognized option '-qversion'
arm-linux-androideabi-gcc.exe: no input files
configure:3125: $? = 1
configure:3145: checking whether the C compiler works
configure:3167: arm-linux-androideabi-gcc -I/cygdrive/d/Projects/android-ndk-r7/platforms/android-8/arch-arm/usr/include
/ -O3 -fno-short-wchar -DU_USING_ICU_NAMESPACE=0 -DU_GNUC_UTF16_STRING=0 -fno-short-enums -nostdlib -I/cygdrive/d/Projec
ts/android-ndk-r7/platforms/android-8/arch-arm/usr/include/ -O3 -fno-short-wchar -DU_USING_ICU_NAMESPACE=0 -DU_GNUC_UTF1
6_STRING=0 -fno-short-enums -nostdlib -lc -Wl,-rpath-link=/cygdrive/d/Projects/android-ndk-r7/platforms/android-8/arch-a
rm/usr/lib/ -L /cygdrive/d/Projects/android-ndk-r7/platforms/android-8/arch-arm/usr/lib/ conftest.c >&5
D:/Projects/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/
4.4.3/../../../../arm-linux-androideabi/bin/ld.exe: cannot find -lc
collect2: ld returned 1 exit status
configure:3171: $? = 1
configure:3209: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:3214: error: in `/cygdrive/d/Projects/__/External/SQLITE/icu-android':
configure:3216: error: C compiler cannot create executables
See `config.log' for more details
Update 3. The changes to config.sub and config.guess worked in that we are now using the right gcc compiler. The -lc failure comes from not being able to find libc.so (which is in android-ndk-r7/platforms/android-8/arch-arm/usr/lib" even though this is in the LDFLAGS. I did have an extra space after -L in the original LDFLAGS, but removing this did not help.
Update 4. According to an older post in http://groups.google.com/group/android-ndk/browse_thread/thread/46295616a889bc12
"The windows ndk toolchain is (thankfully) native to windows, so it
doesnt go through the cygwin translation layer which would translate
/cygdrive paths."
Update 5. Swapped all instances of /cygdrive/d/ with D:/. Now C compiler works though it still doesn't make. Suspect that ICU_CROSS_BUILD has to be in the icu/source directory.
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-linux-androideabi-gcc accepts -g... yes
checking for arm-linux-androideabi-gcc option to accept ISO C89... none needed
checking for arm-linux-androideabi-g++... arm-linux-androideabi-g++
checking whether we are using the GNU C++ compiler... yes
checking whether arm-linux-androideabi-g++ accepts -g... yes
checking how to run the C preprocessor... arm-linux-androideabi-gcc -E
checking for a BSD-compatible install... /usr/bin/install -c
checking for gmake... /usr/bin/gmake
configure: error: D:/Projects/__/External/SQLite/icu-cygwin/config/icucross.mk not found. Please build ICU in
D:/Projects/__/External/SQLite/icu-cygwin first.
Update 6. I re-configured and rbuilt my Cygwin folder in icu-cygwin. Go figure, this time icucross.mk was there. Successful configuration! But...
Update 7 Make did not end up so well.
$ make
D:/Projects/__/External/SQLite/icu/source/config/mh-linux:41: *** target pattern contains no `%'. Stop.
What?!?! It seems that now we want Cygwin paths again.. :(
Update 8. Changed my paths so that HOST_ICU and ICU_CROSS_BUILD use Cygwin paths, but NDK_ROOT is Windows path (since Android NDK ld can't handle cygwin paths).
THis time further but
arm-linux-androideabi-gcc.exe: /cygdrive/d/Projects/__/External/SQLit e/icu/source/stubdata/stubdata.c: No such file or directory
arm-linux-androideabi-gcc.exe: no input files
Seems that what has to happen is that arm-linux-androideabi-gcc needs to be made for cygwin, or the cross-build will not work.
Update 9. It seems that arm-linux-androideabi-gcc does not support cygwin paths - though ndk_build does. However, ICU is set to call arm-linux-androideabi-gcc while "make" requires cygwin paths. Maybe time to switch to OSX or Linux to do this.
Update 10 - Still no success.
Cygwin - Apparently the arm-linux-androideabi Crystax build also doesn't support cygwin paths in -L. Attempting to cross-compile under Cygwin will give the -lc error, since it cannot parse the -L/cygdrive/d/... path to the library. Changing to D:/ helps, but later causes make to fail since it is Cygwin make.
Linux - Using the normal NDK r7 build, configuration will fail with a wchar_t = 0 error. The Crystax NDK build will fix this, and make will fail complaining about uint64_t in Android's sys/type.h. See ICU library in Android NDK. You can force it to be defined and it will lead to yet another error about size mismatch.
OSX - Probably the most successful, compiling using the official build or the Crystax build, it leads directly to the uint64_t bug. If you hack around it, it will lead you to
icu/source/common/ustrenum.cpp:118: error: must #include <typeinfo> before using typeid
Help!
00. Download android ndk http://developer.android.com/tools/sdk/ndk/index.html
example install d:\android-r9b
01. Download install example d:\msys MSys http://www.mingw.org/wiki/MSYS 1.01
02. Download gcc 3.8.1 w64 http://mingw-w64.sourceforge.net/ example install d:\mingw32_64
03. Download icu versin 52.1 http://site.icu-project.org/download/52#TOC-ICU4C-Download
04. Extract icu source code to d:\icu
05. Enter msys use export PATH=/d/msys/1.0/bin:/d/ming32_64/mingw32/bin:$PATH
06. cd /d/icu;mkdir mingw;mkdir android;cd mingw
this is follow icu readme.html cross compile steps
07. cd /d/icu/ming ;../source/runConfigureICU MinGW ;make
no problem,all is working and under /d/icu/mingw/bin generate tools for cross compile later.
08. cd /d/icu/android
09. /d/android-ndk-r9b/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=/d/androidgcc/ -- toolchain=arm-linux-androideabi-4.8
if use window 7/8 64bit add additional options: --system=windowx86_64
10. export PATH again; export PATH=/d/msys/1.0/bin/:/d/androidgcc/bin/:/d/androidgcc/arm-linux-androideabi/bin/
the path must include the ar.exe execute for create library.
11. create shared library.
sh ../source/configure --host=armv6-google-linux --enable-shared=yes --disable-static -with-cross-build=/d/icu/mingw CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ AR=arm-linux-androideabi-ar --with-data-packaging=archive
12. make
all is successful

Categories

Resources