Install valgrind for android, C compiler doesn't work - android

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.

Related

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

__ANDROID__ not defined when building valgrind for android

when I try to configure valgrind for android I get:
Platform variant: vanilla
Primary -DVGPV string: -DVGPV_arm_linux_vanilla=1
I figured out by looking at configure.in that this must be the case because of:
AC_EGREP_CPP([BIONIC_LIBC], [
#if defined(__ANDROID__)
BIONIC_LIBC
#endif
],
GLIBC_VERSION="bionic")
The GLIBC_VERSION is not being set to "bionic", thus __ANDROID__ must not be defined. How can I fix this? The commands I am running are:
export NDKROOT='/home/matt/Desktop/android-ndk-r6'
export HWKIND=emulator
export AR=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar
export LD=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld
export CC=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
cd '/home/matt/Desktop/valgrind-3.8.1'
./autogen.sh
CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm -DANDROID_HARDWARE_$HWKIND" CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" sudo ./configure --prefix=/data/local/Inst --host=armv7-unknown-linux --target=armv7-unknown-linux --with-tmpdir=/sdcard
Information about the machine I'm building on:
Kernel : Linux 3.2.0-23-generic (x86_64)
Default C Compiler : GNU C Compiler version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
Distribution : Linux Mint 13 Maya
Edit: I confirmed that when running $CC directly, the __ANDROID__ is defined. So ./configure is not using $CC?
Edit 2: Adding CC=$CC LD=$LD AR=$AR to the configure gives configure: error: C compiler cannot create executables.
To get this to work, you need to change the parameters passed to the ./configure script to:
sudo ./configure --prefix=/data/local/Inst --host=armv7-unknown-linux\
--target=armv7-unknown-linux --with-tmpdir=/sdcard0\
CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm -DANDROID_HARDWARE_$HWKIND"\
CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm"\
CC=$CC LD=$LD AR=$AR

Build script for Android NDK in linux

How can I build my source for android with NDK.
Already I download ndk and I don't know how can I set arch compiler path.
This is my "build-for-android.sh" code:
#!/bin/sh
cairo=system
curl=system
pal=android
alsa=no
pulse=no
sles=yes
ffmpeg=yes
gallium=no
egl=yes
glx=no
PKG_CONFIG_PATH=$MOONLIGHT_PREFIX/lib/pkgconfig
if [ -d /usr/X11/share/aclocal ]; then
export ACLOCAL_FLAGS="-I /usr/X11/share/aclocal"
fi
./autogen.sh --host=arm-linux-androideabi --prefix=$MOONLIGHT_PREFIX --with-manual-mono=yes --with-testing=no --enable-browser-support --disable-desktop-support --with-unwind=no --with-ffmpeg=$ffmpeg --with-alsa=$alsa --with-pulseaudio=$pulse --with-opensles=$sles --with-pal=$pal --with-curl=$curl --with-cairo=$cairo --with-gallium-path=$gallium --enable-sdk=no --with-egl=$egl --with-glx=$glx CFLAGS="-DPLATFORM_ANDROID -I$MOONLIGHT_PREFIX/include $CFLAGS" LDFLAGS="-L$MOONLIGHT_PREFIX/lib $LDFLAGS" CXXFLAGS="-fno-rtti -DPLATFORM_ANDROID -I$MOONLIGHT_PREFIX/include $CFLAGS"
make $#
when I run it I get error below:
checking for arm-linu-androideabi-g++... no
checking for arm-linu-androideabi-c++... no
checking for arm-linu-androideabi-gpp... no
checking for arm-linu-androideabi-aCC... no
checking for arm-linu-androideabi-cc... no
.
.
.
.
I can see them in ~/Android/android-ndk-r8b/toolchains/arm-linux-androideabi-4.4.3/prebuild/linux-x86/bin/* directory.
OK. I found it.:
First, a standalone toolchain is created to make the configure script easier to use
~$ android-ndk-r5b/build/tools/make-standalone-toolchain.sh --platform=android-8 --install-dir=android-8-toolchain
Next, the toolchain's bin directory is added to the PATH.
~$ export PATH=$PATH:~/android-8-toolchain/bin/

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

Cross Compiling libevent for Android

I'm stuck trying to cross-compile libevent to Android and I'd like to know what I'm doing wrong and get some assistance.
The version I'm trying to build is libevent-2.0.19-stable
I started following the steps described at http://warpedtimes.wordpress.com/2010/02/03/building-open-source-libraries-with-android-ndk/ and how to rewrite the Makefile into android.mk?
The Target Device is a Samsung Galaxy S2 running cyanogenMod 7
After several attempts, the best I did was by running the following steps:
1) Install android NDK and download libevent source code
2) Android NDK downloaded and running in ~/android-ndk/android-ndk-r8b
3) Execute:
export ANDROID_ROOT=~/android-ndk/android-ndk-r8b
export PATH=$PATH:$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/
You need to export the ABI for your device. armeabi-v7a is for devices with ARMv7 or above, any other device uses armeabi.
4) Execute ./configure with the appropriate parameters:
./configure \
--host=arm-linux-androideabi \
CC=arm-linux-androideabi-gcc \
LD=arm-linux-androideabi-ld \
CPPFLAGS="-I$ANDROID_ROOT/platforms/android-8/arch-arm/usr/include/" \
CFLAGS="-nostdlib" \
LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/platforms/android-8/arch-arm/usr/lib/ -L$ANDROID_ROOT/platforms/android-8/arch-arm/usr/lib/" \
LIBS="-lc"
There was a warning in the meantime:
configure: WARNING: if you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used
(I assume it's fine)
As it didn't recognise arm-linux-androideabi as a host, I got a new config.guess and config.sub from http://git.savannah.gnu.org/gitweb/?p=config.git;a=tree (indicated in the previous thread in Stack Overflow)
At this point, when building the source code running "make", it still crashes:
/home/narseo/android-ndk/android-ndk-r8b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: crtbegin_so.o: No such file: No such file or directory
collect2: ld returned 1 exit status
make[2]: *** [libevent.la] Error 1
make[2]: se sale del directorio «/home/narseo/libevent-source/libevent-2.0.19-stable»
make[1]: *** [all-recursive] Error 1
make[1]: se sale del directorio «/home/narseo/libevent-source/libevent-2.0.19-stable»
make: *** [all] Error 2
However, the file seems to be there:
~/android-ndk$ ls $ANDROID_ROOT/platforms/android-8/arch-arm/usr/lib
crtbegin_dynamic.o libc.a libjnigraphics.so libstdc++.so
crtbegin_so.o libc.so liblog.so libthread_db.so
crtbegin_static.o libdl.so libm.a libz.so
crtend_android.o libGLESv1_CM.so libm.so
crtend_so.o libGLESv2.so libstdc++.a
Is there anything I'm doing wrong when running ./configure? Something else I didn't understand even looking at Android's NDK documentation was whether it was mandatory to create an Android.mk or if Makefile was sufficient
Any help will be very welcome!
Cheers
N
Note
This is how I managed to solve it in the end:
Initial PATH:
export ANDROID_ROOT=~/android-ndk/android-ndk-r8b
export PATH=$PATH:$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/
export PATH=$PATH:$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/include/
The errors seem to occur in the linking phase so as it cannot find crtend_so.o and crtbegin_so.o. Following crtbegin_so.o missing for android toolchain (custom build), we add a sym link to them in the source folder
cd source && ln -s $ANDROID_ROOT/platforms/android-8/arch-arm/usr/lib/crtbegin_so.o
ln -s $ANDROID_ROOT/platforms/android-8/arch-arm/usr/lib/crtend_so.o
The ./configure command:
./configure \
--host=arm-linux-androideabi \
CC=arm-linux-androideabi-gcc \
LD=arm-linux-androideabi-ld \
CPPFLAGS="-I$ANDROID_ROOT/platforms/android-8/arch-arm/usr/include/" \
CFLAGS="-nostdlib" \
LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/platforms/android-8/arch-arm/usr/lib/ -L$ANDROID_ROOT/platforms/android-8/arch-arm/usr/lib/" \
LIBS="-lc"
If it fails as it does not recognize system androideabi, try to get newer versions of config.sub and config.guess
It used to crash in the linking phase. Including -lgcc on the CFLAGS solved the issue.
This project builds libevent as a static library on Android here: https://github.com/ventureresearch/libevent
It includes the Android.mk and generated config files to build it cleanly.
Note that we are building it for inclusion into an Android device image, and NOT building through the NDK. It would probably still be a good place to start.
Try this
./configure --host=arm-linux-androideabi CC="$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=$SYSROOT" CFLAGS='-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16'
It works for me.
Try with below configurations:
ANDROID_SYSROOT=$ANDROID_ROOT/platforms/android-8/arch-arm/
./configure --host=arm-linux-androideabi CFLAGS=--sysroot=$ANDROID_SYSROOT LDFLAGS=--sysroot=$ANDROID_SYSROOT

Categories

Resources