【问题标题】:cross compiling for android using NDK fails with compiler error使用 NDK 对 android 进行交叉编译失败并出现编译器错误
【发布时间】:2011-06-16 21:07:49
【问题描述】:

我正在从HTCs developer website 上找到的源代码编译一个nexus one android 内核。我通过从 android 开发站点 DLing android NDK 获得了一个 ARM 工具链。我可以毫无问题地运行 make clean 和 make defconfig,但是当我运行 make 时,它​​只会在遇到编译器错误之前得到这么多。

目前我看到以下内容:

$MY_DIR/nexus_one/arch/arm/include/asm/glue.h:156:29: 错误:'#' 后面没有宏参数

违规行是:

1  /*
2  * Instruction Fault Status Register.  (New register as of ARMv6)
3  * If processor has IFSR then set value, else set translation fault
4  */
5 #if defined(CONFIG_CPU_ABRT_EV7) || defined(CONFIG_CPU_ABRT_EV6)
6 # define CPU_PABORT_IFSR(reg)    mrc p15, 0, reg, cr5, cr0, 1         @asm macro;
7 #else
8 # define CPU_PABORT_IFSR(reg)    mov reg, #5                          @asm macro;
9 #endif

具体来说,上面的第 8 行是编译器的内容。显然你不能有第二个 # 符号,但我不太确定这段代码中发生了什么,而且它看起来很重要,所以我不想碰它。

我猜我可能使用了错误的工具链进行编译?或者也许我以某种方式配置错误?有人知道这是怎么一回事吗?

谢谢, 布莱恩

【问题讨论】:

  • fyi,我现在已经用 4 种不同的工具链尝试过这个,所以我开始认为特定的交叉编译器不是问题。我不知道还有什么可以看的。

标签: android android-ndk cross-compiling


【解决方案1】:

我强烈建议您使用适用于 Linux 的 CodeSourcery 工具链来编译 Linux 内核。

【讨论】:

  • 那是我第一次尝试认为。我会再试一次,看看它是否有所作为。谢谢!
  • 只是好奇;你特别推荐这个工具链的原因是什么?
  • 所以我之前曾尝试过来自 codesourcery 的类似但不同的工具链,现在在这两种情况下都看到了相同的错误(加上 ndk 工具链)。所以我想问题一定是别的。
【解决方案2】:

原来这与特定的工具链无关。 # 符号需要某种“转义”。解决方法如下:

/* this is needed to get the mov reg, 5 macro to compile and function correctly */
#define hash_hackery #
#define f(x) x

#if defined(CONFIG_CPU_ABRT_EV7) || defined(CONFIG_CPU_ABRT_EV6)
# define CPU_PABORT_IFSR(reg)   mrc p15, 0, reg, cr5, cr0, 1         @asm macro;
#else
# define CPU_PABORT_IFSR(reg)   mov reg, f(hash_hackery)5            @asm macro;
#endif

This post 在寻找答案方面提供了非常丰富的信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-06
    • 1970-01-01
    • 2018-11-26
    • 2018-05-26
    • 1970-01-01
    • 2019-12-26
    • 2020-12-05
    • 2012-12-28
    相关资源
    最近更新 更多