【问题标题】:"The C Compiler [...] is not able to compile a simple test program" using CMake and Android NDK“C 编译器 [...] 无法编译简单的测试程序”使用 CMake 和 Android NDK
【发布时间】:2016-12-27 14:11:33
【问题描述】:

我目前正在 Windows 上测试 Visual Studio 2017 RC CMake 对 Android NDK C++ 项目的支持并遇到问题。

当我尝试使用以下命令生成 CMake 缓存时:

<cmake.exe> -G "Visual Studio 15 2017" -DCMAKE_INSTALL_PREFIX:PATH=<install_path> -DCMAKE_TOOLCHAIN_FILE="<androidNDK_path>\build\cmake\android.toolchain.cmake" -DANDROID_TOOLCHAIN=gcc -DANDROID_ABI="armeabi-v7a with NEON" --DCMAKE_BUILD_TYPE="Debug" <source>

我收到以下错误(如果我不强制 gcc,clang 也会发生同样的情况):

The C compiler "<androidNDK_path>/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc.exe" is not able to compile a simple test program.

在此之前,我收到警告说 C 和 CXX 编译器的标识未知,但我不确定这是否相关。

我在临时测试项目中遇到了更多错误,但它们似乎没有提供很多信息,例如

C:\Program Files (x86)\Microsoft Visual
Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(57,5):
error MSB4018: The "VCMessage" task failed unexpectedly.

C:\Program Files (x86)\Microsoft Visual
Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(57,5):
error MSB4018: System.FormatException: Index (zero based) must be greater
than or equal to zero and less than the size of the argument list.

我该如何解决这个问题?

【问题讨论】:

    标签: c++ android-ndk cmake cross-platform visual-studio-2017


    【解决方案1】:

    对于发现这篇文章并遇到相同问题的每个人:问题似乎出在 Visual Studio 生成器上。此外,Android 工具链似乎需要一个带有“make”路径的参数。所以为了解决这两个问题,我安装了 MSYS (http://www.mingw.org/wiki/MSYS) 并将 CMake 命令更改为:

    <cmake.exe>  -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX:PATH=<install_path> -DCMAKE_TOOLCHAIN_FILE="<androidNDK_path>\build\cmake\android.toolchain.cmake" -DCMAKE_MAKE_PROGRAM="<MinGW_path>\msys\1.0\bin\make.exe" -DANDROID_TOOLCHAIN=gcc -DANDROID_ABI="armeabi-v7a with NEON" --DCMAKE_BUILD_TYPE="Debug" <source>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-16
      • 2021-03-18
      • 1970-01-01
      • 1970-01-01
      • 2021-01-23
      • 1970-01-01
      • 2015-08-13
      相关资源
      最近更新 更多