简体   繁体   English

多个sysroot导致从makefile到错误的gcc调用假定Android NDK路径。

[英]Multiple sysroot results in gcc calls from makefile to erroneous assume Android NDK path.

This is a most vexing issue. 这是一个最棘手的问题。 When I run my makefile I see two sysroot in the output: 当我运行我的makefile时,我在输出中看到两个sysroot:

    ubuntu@ubuntu:~/Desktop/LatestAndroidstuff/CmE_source_DAL_1.7_3564/CmCompact$ make
platform/wince/WibuCmHID/rules.mak:31: WibuCmHID only for Windows CE
/home/ubuntu/my-android-toolchain/bin//arm-linux-androideabi-gcc  -I./ -I./external/hidapi/include  -Os  -std=c99 -Wall -Wextra -fno-short-enums -fno-strict-aliasing --sysroot=/home/ubuntu/my-android-toolchain/sysroot --sysroot=/home/ubuntu/android-ndk-r13b/platforms/android-14/arch-arm  -o obj/release/android/armeabi-v7a/static/w_refcount.o -c   base/w_refcount.c 
In file included from base/w_refcount.c:29:0:
./base/w_define.h:31:19: fatal error: stdio.h: No such file or directory
 #include <stdio.h>
                   ^
compilation terminated.
rules.mak:54: recipe for target 'obj/release/android/armeabi-v7a/static/w_refcount.o' failed
make: *** [obj/release/android/armeabi-v7a/static/w_refcount.o] Error 1

If I edit the failing command and remove the extra sysroot (the second one), it works. 如果我编辑失败的命令并删除额外的sysroot(第二个),它的工作原理。

/home/ubuntu/my-android-toolchain/bin//arm-linux-androideabi-gcc  -I./ -I./external/hidapi/include  -Os  -std=c99 -Wall -Wextra -fno-short-enums -fno-strict-aliasing --sysroot=/home/ubuntu/my-android-toolchain/sysroot --sysroot=/home/ubuntu/android-ndk-r13b/platforms/android-14/arch-arm  -o obj/release/android/armeabi-v7a/static/w_refcount.o -c   base/w_refcount.c 

Problem is, I have looked all over the makefile. 问题是,我已经查看了整个makefile。 The makefile is simple enough: makefile很简单:

WBSMAK_ANDROID_NDK_HOME=/home/ubuntu/android-ndk-r13b
SYSROOT=/home/ubuntu/my-android-toolchain/sysroot
ANDROID_TOOLCHAIN_DIR=/home/ubuntu/my-android-toolchain/bin/
WBSMAK_ANDROID_CC=${ANDROID_TOOLCHAIN_DIR}/arm-linux-androideabi-gcc
WBSMAK_ANDROID_LD=${ANDROID_TOOLCHAIN_DIR}/arm-linux-androideabi-ld
WBSMAK_ANDROID_AR=${ANDROID_TOOLCHAIN_DIR}/arm-linux-androideabi-ar
WBSMAK_ANDROID_RANLIB=${ANDROID_TOOLCHAIN_DIR}/arm-linux-androideabi-ranlib

SHELL       := /bin/bash
AR          := WBSMAK_ANDROID_AR
CC          ?= WBSMAK_ANDROID_CC
LD          ?= WBSMAK_ANDROID_LD
RANLIB      := WBSMAK_ANDROID_RANLIB

In order to make the file pick up sysroot: 为了使文件拿起sysroot:

CFLAGS_ARCH := --sysroot=${SYSROOT} CFLAGS_ARCH:= --sysroot = $ {SYSROOT}

But there is no mention at all in the makefile about that other second sysroot nor that path that shows up. 但是在makefile中根本没有提到关于那个其他第二个sysroot以及那个出现的路径。 Also, I looked and made sure it's not picking up an environment variable. 此外,我查看并确保它没有获取环境变量。

ubuntu@ubuntu:~/my-android-toolchain$ printenv | grep SYSROOT
ANDROID_SYSROOT=
LINARO_SYSROOT=/home/ubuntu/linaro-toolchain-4.6/arm-unknown-linux-gnueabi/sysroot
SYSROOT=/home/ubuntu/my-android-toolchain/

The environment sysroot it pointed to where I want it. 环境sysroot它指向我想要的地方。 If I move the Android NDK folder and all its stuff out of the path, that is nowhere in the makefile, then I get the error. 如果我将Android NDK文件夹及其所有内容移出路径,那在makefile中就没有了,那么我就会收到错误。 If I have the folder where the extra sysroot is, then the library compiles and links, but it crashes on the Android device, which is Android 21, not 14. I don't know why it's always Android 14. Could I be missing some setting somewhere? 如果我有额外sysroot所在的文件夹,那么库编译和链接,但它在Android设备上崩溃,这是Android 21,而不是14.我不知道为什么它总是Android 14.我可能会遗漏一些设置在某个地方? Perhaps when I created the standalone tools using make-standalone-toolchain.sh something hardcoded went in so the calls to /home/ubuntu/my-android-toolchain/bin/arm-linux-androideabi-gcc always searches for the android-14 path? 也许当我使用make-standalone-toolchain.sh创建独立工具时硬编码进入了所以调用/ home / ubuntu / my-android-toolchain / bin / arm-linux-androideabi-gcc总是搜索android-14路径?

Very vexing problem. 很烦人的问题。 I have been all over the makefile. 我一直在makefile上。 I don't know why the gcc keeps picking up that android 14 sysroot. 我不知道为什么gcc不断拿起那个android 14 sysroot。 Could I be only providing for the compilation but the linking is pulling up a default sysroot? 我可以只提供编译,但链接是否提取默认的sysroot?

Alright the issue appears to have been a carefully sidelines .mak file in a subfolder that was looking for a string in a string of an existing field and on finding that, was using ANDROID_ARCH for the --sysroot in the actual gcc call. 好吧,问题似乎是在子文件夹中一个仔细的边线.mak文件,该子文件夹在现有字段的字符串中查找字符串并在查找时,在实际的gcc调用中使用ANDROID_ARCH作为--sysroot。 But to the credit of who wrote it, it did have the other -march setting needed for proper compile and linking of the android native module. 但是对于谁编写它的功劳,它确实具有正确编译和链接android原生模块所需的其他-march设置。

Moral of the story: always surf around the folders and take a glance at everything. 故事的道德:总是浏览文件夹并浏览一切。

(of course my app still crashes but that's another matter to find that out... ) (当然我的应用程序仍然崩溃,但另一个问题是发现...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM