android工具链体系,android - Android NDK中预构建工具链和自定义工具链编译器之间的区别...

所以我试图弄清楚如何为Android构建ICU。最初,我尝试使用独立的工具链来实现这一目标,经过一番战斗之后,我至少能够在x86_64 arch上做到这一点(没有尝试过使用其他工具)。但是我不想拥有完全自定义的构建系统,因此我决定弄清楚如何使用预构建工具链进行构建。而且我发现它的行为非常不同-这很奇怪。因此,这是我实际尝试使用独立工具链配置ICU时的命令:icu/source/configure --disable-shared --enable-static --disable-dyload

--disable-extras --disable-tests --disable-samples --prefix=/icu/build --host=x86_64-linux-android --with-cross-build=/toplay/icu/icu_linux CC=/custom_toolchain/bin/clang

CXX=/custom_toolchain/bin/clang++

LD=/custom_toolchain/bin/x86_64-linux-android-ld

AR=/custom_toolchain/bin/x86_64-linux-android-ar

CFLAGS="-fPIC -DANDROID -fdata-sections -ffunction-sections"

CXXFLAGS="-fPIC -DANDROID -frtti -fno-exceptions -fdata-sections

-ffunction-sections"

因此,具有相同的命令,但仅更改预构建工具链中的编译器和工具,如下所示:

icu/source/configure --disable-shared --enable-static --disable-dyload

--disable-extras --disable-tests --disable-samples --prefix=/icu/build --host=x86_64-linux-android --with-cross-build=/toplay/icu/icu_linux CC=/ndk-bundle/toolchains/x86_64-4.9/prebuilt/linux-x86_64/bin/clang

CXX=/ndk-bundle/toolchains/x86_64-4.9/prebuilt/linux-x86_64/bin/clang++

LD=/ndk-bundle/toolchains/x86_64-4.9/prebuilt/linux-x86_64/bin/x86_64-linux-android-ld

AR=/ndk-bundle/toolchains/x86_64-4.9/prebuilt/linux-x86_64//bin/x86_64-linux-android-ar

CFLAGS="-fPIC -DANDROID -fdata-sections -ffunction-sections"

CXXFLAGS="-fPIC -DANDROID -frtti -fno-exceptions -fdata-sections

-ffunction-sections"

我得到非常不同的配置步骤结果。我在其中放置了TLDR:主要差异:在预构建工具链案例中,系统无法理解它是交叉编译模式,它会找到nl_langinfo,strtod_l在android中不可用)和独立工具-链最初可以构建ICU,在构建前的情况下构建过程最终会中断。

所以我的问题是:在预构建和独立情况下,编译器和工具有什么区别?为了使其在预构建情况下工作,我需要添加哪些标志/设置?

最佳答案

这是预期的行为。我已经在our bugtracker上回答了这个问题。Our Clang defaults to targeting x86 Linux, not any flavor of Android. Setting up your target flags is one of the many things standalone toolchains do.

I'm not really sure what problem you're trying to solve. Whatever you get working with autoconf is going to essentially be a cobbled together standalone toolchain. Standalone toolchains exist entirely for dealing with this kind of scenario.

要在此处回答您的特定问题:

what is the difference between compilers and tools in prebuild and standalone case and what flags/settings I need to add to make it work in prebuild case?

独立工具链是具有不同目录布局的预构建工具链(因此,编译器可以推断binutils,sysroot和STL的位置)和一些默认标志(如lang的-target)。如果您要使它正常工作,那么您可能只是重新发明了这个轮子(可以使用-gcc-toolchain和一堆--sysroot,-isystem和-L东西,而不是更改目录结构。

万一“为什么这不能开箱即用?”是一个后续问题,请记住,在Android中,您有许多体系结构,甚至更多的目标版本的OS,以及少数STL供您选择。目前Clang和GCC都无法以能够处理Android所有版本的方式进行设置(从长远来看,我确实希望对此进行更改,但这在the road之下还是相当不错的)。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值