“没有输入文件”使用 Android NDK r6b 的 gcc 构建时

发布于 2024-12-26 12:40:16 字数 7306 浏览 1 评论 0原文

从纽约假期回来后,我在构建项目时遇到了一个奇怪的问题,我以前没有遇到过任何类似的问题。
每个项目都是一个共享/静态库或一个使用 gcc 交叉编译器 (cygwin) 使用 NDK 6b 构建的 Android 应用程序。
操作系统是Windows 7(32位),我没有安装/卸载/重新安装任何相关软件(假期期间:)。

我尝试构建标准 NDK 示例 hello-jni - 发生同样的错误。
日志:

A.User@A-User-L ~/Devel/hello-jni
$ ndk-build
Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Compile thumb  : hello-jni <= hello-jni.c
arm-linux-androideabi-gcc.exe: /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/jni/hello-jni.c: No such file or directory
arm-linux-androideabi-gcc.exe: no input files
/cygdrive/c/dev/Android/android-ndk-r6b/build/core/build-binary.mk:217: recipe for target `/cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o' failed
make: *** [/cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o] Error 1

详细日志(抱歉,字母过多):

A.User@A-User-L ~/Devel/hello-jni
$ ndk-build V=1
rm -f /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi/lib*.so /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi-v7a/lib*.so /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/x86/lib*.so
rm -f /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi/gdbserver /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi-v7a/gdbserver /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/x86/gdbserver
rm -f /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi/gdb.setup /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi-v7a/gdb.setup /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/x86/gdb.setup
Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
mkdir -p /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi
install -p /cygdrive/c/dev/Android/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/gdbserver /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
mkdir -p /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi
echo "set solib-search-path /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi" > /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi/gdb.setup
echo "directory /cygdrive/c/dev/Android/android-ndk-r6b/platforms/android-8/arch-arm/usr/include /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/jni /cygdrive/c/dev/Android/android-ndk-r6b/sources/cxx-stl/system" >> /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi/gdb.setup
Compile thumb  : hello-jni <= hello-jni.c
/cygdrive/c/dev/Android/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc -MMD -MP -MF /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org -fpic  -ffunction-sections  -funwind-tables  -fstack-protector  -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__  -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__   -Wno-psabi -march=armv5te  -mtune=xscale  -msoft-float  -mthumb  -Os  -fomit-frame-pointer  -fno-strict-aliasing  -finline-limit=64  -I/cygdrive/e/Users/A.User.ORG/Devel/hello-jni/jni  -DANDROID  -Wa,--noexecstack  -O0 -g  -I/cygdrive/c/dev/Android/android-ndk-r6b/platforms/android-8/arch-arm/usr/include  -c   /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/jni/hello-jni.c -o /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o &&  ( if [ -f "/cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org" ]; then  awk -f /cygdrive/c/dev/Android/android-ndk-r6b/build/awk/convert-deps-to-cygwin.awk /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org > /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d &&  rm -f /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org;  fi )
/cygdrive/c/dev/Android/android-ndk-r6b/build/core/build-binary.mk:217: recipe for target `/cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o' failed
arm-linux-androideabi-gcc.exe: /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/jni/hello-jni.c: No such file or directory
arm-linux-androideabi-gcc.exe: no input files
make: *** [/cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o] Error 1

Android.mk 的内容非常标准:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := hello-jni
LOCAL_SRC_FILES := hello-jni.c

include $(BUILD_SHARED_LIBRARY)

我知道 Windows 上的 cygwin 不支持符号链接- 目录树中没有符号链接。
没有残酷的防病毒软件在运行,只有 Windows Defender。
我像去年一样以普通用户身份运行构建(即没有凭据更改)。

可能出了什么问题

相关问题:


[Update] Process Monitor shows that the cross-compiler tries to access the "wrong path": `E:\cygdrive\e\Users\A.User.ORG\Devel\hello-jni\jni\hello-jni.c`... I wonder how this tool worked before! More info is to follow as soon as I dig it up :)
[Update#2] On another PC (Windows XP 32-bit) which has almost the same set of tools installed (same version of Cygwin, Android NDK), the log looks different:
Compile thumb  : hello-jni <= hello-jni.c
/cygdrive/c/dev/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc -MMD -MP -MF E:/Users/A.User.SURC/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -IE:/Users/A.User.SURC/Devel/hello-jni/jni -DANDROID  -Wa,--noexecstack -O0 -g -IC:/dev/android-ndk-r6b/platforms/android-8/arch-arm/usr/include -c  E:/Users/A.User.SURC/Devel/hello-jni/jni/hello-jni.c -o E:/Users/A.User.SURC/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o && ( if [ -f "E:/Users/A.User.SURC/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org" ]; then awk -f /cygdrive/c/dev/android-ndk-r6b/build/awk/convert-deps-to-cygwin.awk E:/Users/A.User.SURC/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org > E:/Users/A.User.SURC/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d && rm -f E:/Users/A.User.SURC/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org; fi )

由于一些不清楚的原因 gcc 在这里提供了 Windows 风格的路径...这就是进程应该如何交互的。
那么现在的问题是如何指示cygwin/NDK传递正确的路径

After returning from NY holidays I've faced a queer problem with building the projects I hadn't had any similar problems before.
Each project is a shared/static library or an application for Android built with NDK 6b using gcc cross-compiler (cygwin).
The OS is Windows 7 (32-bit), and I haven't installed/uninstalled/reinstalled any relevant software (during holidays :).

I've tried to build the standard NDK sample hello-jni - same error occurs.
The log:

A.User@A-User-L ~/Devel/hello-jni
$ ndk-build
Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Compile thumb  : hello-jni <= hello-jni.c
arm-linux-androideabi-gcc.exe: /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/jni/hello-jni.c: No such file or directory
arm-linux-androideabi-gcc.exe: no input files
/cygdrive/c/dev/Android/android-ndk-r6b/build/core/build-binary.mk:217: recipe for target `/cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o' failed
make: *** [/cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o] Error 1

The verbose log (sorry for overwhelming with letters):

A.User@A-User-L ~/Devel/hello-jni
$ ndk-build V=1
rm -f /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi/lib*.so /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi-v7a/lib*.so /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/x86/lib*.so
rm -f /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi/gdbserver /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi-v7a/gdbserver /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/x86/gdbserver
rm -f /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi/gdb.setup /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi-v7a/gdb.setup /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/x86/gdb.setup
Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
mkdir -p /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi
install -p /cygdrive/c/dev/Android/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/gdbserver /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
mkdir -p /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi
echo "set solib-search-path /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi" > /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi/gdb.setup
echo "directory /cygdrive/c/dev/Android/android-ndk-r6b/platforms/android-8/arch-arm/usr/include /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/jni /cygdrive/c/dev/Android/android-ndk-r6b/sources/cxx-stl/system" >> /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/libs/armeabi/gdb.setup
Compile thumb  : hello-jni <= hello-jni.c
/cygdrive/c/dev/Android/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc -MMD -MP -MF /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org -fpic  -ffunction-sections  -funwind-tables  -fstack-protector  -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__  -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__   -Wno-psabi -march=armv5te  -mtune=xscale  -msoft-float  -mthumb  -Os  -fomit-frame-pointer  -fno-strict-aliasing  -finline-limit=64  -I/cygdrive/e/Users/A.User.ORG/Devel/hello-jni/jni  -DANDROID  -Wa,--noexecstack  -O0 -g  -I/cygdrive/c/dev/Android/android-ndk-r6b/platforms/android-8/arch-arm/usr/include  -c   /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/jni/hello-jni.c -o /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o &&  ( if [ -f "/cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org" ]; then  awk -f /cygdrive/c/dev/Android/android-ndk-r6b/build/awk/convert-deps-to-cygwin.awk /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org > /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d &&  rm -f /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org;  fi )
/cygdrive/c/dev/Android/android-ndk-r6b/build/core/build-binary.mk:217: recipe for target `/cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o' failed
arm-linux-androideabi-gcc.exe: /cygdrive/e/Users/A.User.ORG/Devel/hello-jni/jni/hello-jni.c: No such file or directory
arm-linux-androideabi-gcc.exe: no input files
make: *** [/cygdrive/e/Users/A.User.ORG/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o] Error 1

The content of Android.mk is pretty standard:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := hello-jni
LOCAL_SRC_FILES := hello-jni.c

include $(BUILD_SHARED_LIBRARY)

I know that cygwin on Windows doesn't support symbolic links - there are no symbolic links in the directories tree.
There is no cruel antivirus running, just Windows Defender.
I run the build as an ordinary user as I used to do last year (i.e. no credential changes).

What may be wrong?

Related issues:


[Update] Process Monitor shows that the cross-compiler tries to access the "wrong path": `E:\cygdrive\e\Users\A.User.ORG\Devel\hello-jni\jni\hello-jni.c`...
I wonder how this tool worked before!
More info is to follow as soon as I dig it up :)


[Update#2] On another PC (Windows XP 32-bit) which has almost the same set of tools installed (same version of Cygwin, Android NDK), the log looks different:

Compile thumb  : hello-jni <= hello-jni.c
/cygdrive/c/dev/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc -MMD -MP -MF E:/Users/A.User.SURC/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -IE:/Users/A.User.SURC/Devel/hello-jni/jni -DANDROID  -Wa,--noexecstack -O0 -g -IC:/dev/android-ndk-r6b/platforms/android-8/arch-arm/usr/include -c  E:/Users/A.User.SURC/Devel/hello-jni/jni/hello-jni.c -o E:/Users/A.User.SURC/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o && ( if [ -f "E:/Users/A.User.SURC/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org" ]; then awk -f /cygdrive/c/dev/android-ndk-r6b/build/awk/convert-deps-to-cygwin.awk E:/Users/A.User.SURC/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org > E:/Users/A.User.SURC/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d && rm -f E:/Users/A.User.SURC/Devel/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o.d.org; fi )

For some unclear reasons gcc is fed with Windows-style paths here... and this is how the processes should interact.
So the question now is how to instruct cygwin/NDK to pass proper paths?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

轻拂→两袖风尘 2025-01-02 12:40:16

源代码文件是否位于正确的目录中?检查错误消息中打印的路径。 c/c++ 源文件必须位于 jni 子目录中,而不是 src 子目录中。

另外,不确定这是否有帮助,最新的 SDK/NDK 版本应该支持 Windows 本机批处理文件。不再需要 Cygwin(尽管仍然缺乏调试支持)。尝试从运行 ndk-build 的 Windows 命令行进行构建。

另外,之前是否有相同的设置(在具有相同文件/目录的同一台计算机上)?

Is the source code file in the correct directory? Check the path printed in the error message. c/c++ source files have to be in the jni sub directory, not the src one.

Also, not sure if that helps, the latest SDK/NDK versions should support Windows native batch files. Cygwin is no longer required (debugging support is still lacking though). Try to build from the windows command line running ndk-build.

Also, did the same setup work before (on the same machine with same files/directories)?

放肆 2025-01-02 12:40:16

我终于用 ndk-build 找到了我的电脑上出现问题的原因。

简而言之:这是由于cygwin的mountmount.exe之间的冲突引起的,这是“Client for NFS”功能的一部分(我最近确实安装了它)与 Telnet 客户端一起)。

更多信息

我发现文章“使用 NDK-r5b 和 Cygwin 构建必要的 Qt 框架" - 此人遇到了问题使用NDK包含路径,他通过修改脚本解决了这个问题。
这个提示帮助我在 NDK 中找到了相应的脚本 gen-windows-host-path.awk,它执行路径转换(从 cygwin-style 到 Windows)。
它依赖于 mount,后者在不带参数调用时列出所有驱动器。
事实证明,我的电脑上的 mount 没有看到任何驱动器...因为它是 mount.exe 位于 /cygdrive/c/Windows/system32 / 来自 Windows,而不是来自 Cygwin 的 /usr/bin/mount
默认情况下,Windows 中不存在 mount.exe,如果是这种情况,那么您可能已经安装了“NFS 客户端”。
因此,解决方案(实际上是一种解决方法)是从 Windows 中卸载“NFS 客户端”功能

I've finally tracked down the cause of the problems on my PC with ndk-build.
In short: it was caused by the conflict between cygwin's mount and mount.exe, which is a part of the feature "Client for NFS" (I indeed have installed it recently along with Telnet Client).

More information

I've found a similar problem mentioned in the article "Building Necessitas Qt framework using NDK-r5b and Cygwin" - the person had encountered issues with NDK include paths, which he solved by modifying the scripts.
This hint helped me to locate the corresponding script gen-windows-host-path.awk in NDK, which performs the paths transformation (from cygwin-style to Windows).
It relies on mount, which lists all drives when called without parameters.
And it turned out that mount on my PC didn't see any drives... because it was mount.exe at /cygdrive/c/Windows/system32/ from Windows, and not /usr/bin/mount from Cygwin.
By default mount.exe is not present in Windows, and if this is the case then you probably have installed "Client for NFS".
So the solution (actually a workaround) is to uninstall "Client for NFS" feature from Windows.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文