[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How To Configure for Android?
From: |
Jeffrey Walton |
Subject: |
Re: How To Configure for Android? |
Date: |
Mon, 7 Oct 2013 15:31:49 -0400 |
Thanks Eric,
>> I'm not sure why I'm trying to trick the build system with host=arm
>> since the host is x86_64.
>
> You're lying. You're telling configure that your compiler is on an
> arm-based host, when it is really on an x86_64-based host.
OK, thanks.
> (I don't know the target triple for an android system, unfortunately).
Yeah, neither do I (for Mac OS X or Android).
For others who stumble upon this thread:
1) Set your PATH so the Android NDK tools (arm-linux-androideabi-cpp,
arm-linux-androideabi-gcc, and friends) are on PATH:
$ echo $PATH
/opt/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin:
/opt/android-sdk-macosx/tools/:/opt/android-sdk-macosx/platform-tools/:
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:
/opt/X11/bin:/usr/local/MacGPG2/bin
2) Ensure ANDROID_NDK_ROOT is set (this is an Android requirement, see
https://groups.google.com/d/msg/android-ndk/qZjhOaynHXc/Szy_KYY9GcwJ):
$ echo $ANDROID_NDK_ROOT
/opt/android-ndk-r9
3) Export the tools:
export CPP=arm-linux-androideabi-cpp
export CC=arm-linux-androideabi-cc
...
export LD=arm-linux-androideabi-ld
...
4) Export CPPFLAGS, CFLAGS, and CXXFLAGS *with* SYSROOT (some
autotools tests don't honor the config option):
$ echo $ANDROID_SYSROOT
/opt/android-ndk-r9/platforms/android-14/arch-arm
export CPPFLAGS="--sysroot=$ANDROID_SYSROOT"
export CFLAGS="--sysroot=$ANDROID_SYSROOT"
export CXXFLAGS="--sysroot=$ANDROID_SYSROOT"
5) Configure as follows (`--build=arm-android` breaks config):
$ ./configure --host=x86_64-darwin --build=arm --with-sysroot=$ANDROID_SYSROOT
checking build system type... arm-unknown-none
checking host system type... x86_64-pc-none
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
I owe you a beer or two if you make it to Maryland.
Jeff
On Mon, Oct 7, 2013 at 3:05 PM, Eric Blake <address@hidden> wrote:
> On 10/07/2013 12:56 PM, Jeffrey Walton wrote:
>>
>> $ ./configure --host=arm --build=arm --with-sysroot=$ANDROID_SYSROOT
>
>> configure:3644: error: cannot run C compiled programs.
>> If you meant to cross compile, use `--host'.
>> See `config.log' for more details
>>
>> I'm not sure why I'm trying to trick the build system with host=arm
>> since the host is x86_64.
>
> You're lying. You're telling configure that your compiler is on an
> arm-based host, when it is really on an x86_64-based host. Because your
> --host and --build match, configure then assumes that you are not
> cross-compiling. To cross-compile, --host and --build MUST be
> different. Don't lie to configure. Try
>
> ./configure --host=x86_64 --build=arm
>
> or even better, use full target triples, as in:
>
> ./configure --host=x86_64-unknown-linux-gnu --build=...
>
> (I don't know the target triple for an android system, unfortunately).
>
>> And it feels like I am not specifying the
>> target properly, but `configure --help` does not list any target
>> configuration options.
>
> config.guess will show you a reasonable guest for host (there's a bug
> request that we shouldn't require explicit --host any more, now that
> we've had years of config.guess doing it right - but that's a story for
> another thread and a future autoconf release; it would still be years
> before you could ever assume all packages have been retooled to avoid
> needing an explicit --host); and reading config.sub will show you all
> the known triples that GNU software has tried to target.