【问题标题】:Cross Compiling of C source file to Android Arm将 C 源文件交叉编译到 Android Arm
【发布时间】:2018-10-17 10:29:25
【问题描述】:

我正在尝试使用 nim 在 Windows 中在移动设备中创建 C 语言交叉编译器。我一直在编译,但我无法使用 USB 调试将它导出/推送到我的手机上 下面是我创建的批处理文件.. 谁能告诉我出了什么问题?我只想使用 gcc 或 clang 直接编译到我的移动设备上。

@echo off

set PATH=%PATH%;C:/Users/PCTechRinz/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows/bin

 nim c --cpu:arm --os:android --compileOnly hello.nim

path = C:/cygwin/bin

g++ -I../sysroot/usr/include -I/path=D:/Installer/nim-0.19.0/lib -pie -o hello.bin hello.cpp stdlib_system.cpp

path = C:/Users/PCTechRinz/AppData/Local/Android/Sdk/platform-tools
 adb root
 adb push hello.bin /data/local/tmp/hello.bin
 adb shell 

cd /data/local/tmp/hello.bin
chmod 755 hello
./hello
pause

下面是我得到的

Hint: used config file 'D:\Installer\nim-0.19.0\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: hello [Processing]
Hint: operation successful (12267 lines compiled; 0.268 sec total; 10.773MiB pea
kmem; Debug Build) [SuccessX]
adb: error: failed to get feature set: no devices/emulators found
error: no devices/emulators found
The system cannot find the path specified.
'chmod' is not recognized as an internal or external command,
operable program or batch file.
'.' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .

我已在手机上启用 USB 调试

【问题讨论】:

    标签: android c android-ndk cross-compiling


    【解决方案1】:

    您必须使用 Android 工具链来为 Android 构建。您系统的 g++ 面向 Windows,而不是 Android。

    我强烈建议使用 ndk-build 或 CMake,但如果您出于某种原因需要直接使用 Clang,您应该使用 standalone toolchain

    【讨论】:

      猜你喜欢
      • 2010-10-07
      • 2015-10-21
      • 1970-01-01
      • 2016-01-15
      • 1970-01-01
      • 2014-06-13
      • 1970-01-01
      • 2020-04-10
      • 1970-01-01
      相关资源
      最近更新 更多