"C编译器无法编译简单的测试程序".使用CMake和Android NDK [英] "The C Compiler [...] is not able to compile a simple test program" using CMake and Android NDK

查看:230
本文介绍了"C编译器无法编译简单的测试程序".使用CMake和Android NDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm currently testing the Visual Studio 2017 RC CMake support for Android NDK C++ projects on Windows and encountered an issue.

当我尝试使用以下方法生成CMake缓存时:

When I try to generate the CMake cache with:

<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中也会发生同样的情况):

I get the following error (The same happens with clang if I don't force gcc):

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编译器的标识,但是我不确定这是否有意义.

Before that I get the warnings that the identification of the C and CXX compilers are unknown but I'm not sure that's relevant.

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

I get more errors for the temporary test project but they don't seem to give a lot of information like

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.

如何解决此问题?

推荐答案

对于所有发现此帖子且有相同问题的人:问题似乎出在Visual Studio生成器上.同样,Android工具链似乎也需要一个带有"make"路径的参数.因此,为解决这两个问题,我安装了MSYS( http://www.mingw.org/wiki/MSYS),并将CMake命令更改为:

For everybody who finds this post and has the same issue: the problem seems to be the Visual Studio generator. Also it seems like the Android toolchains requires an argument with the path to "make". So to solve both I installed MSYS (http://www.mingw.org/wiki/MSYS) and changed the CMake command to:

<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>

这篇关于"C编译器无法编译简单的测试程序".使用CMake和Android NDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆