CMake/Android 错误:“无法编译简单的测试程序”

Tho*_*itz 5 c++ qt android cmake

我正在尝试编译 Android 的 CMake 项目。

我使用 QtCreator 创建和编译项目。使用 QMake 工作正常,但 CMake 项目不起作用。

CMake Project parsing failed.
Running "C:\Android\android-sdk\cmake\3.10.2.4988404\bin\cmake.exe -E server "--pipe=\\.\pipe\{78eb9a25-fbdf-4ac7-b840-8cfe89cbd883}" --experimental" in C:\Users\Thorsten\AppData\Local\Temp\QtCreator-Zmienl\qtc-cmake-KUabkXqG.
Starting to parse CMake project, using: "-DCMAKE_CXX_COMPILER:STRING=C:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe", "-DCMAKE_C_COMPILER:STRING=C:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe", "-DCMAKE_PREFIX_PATH:STRING=C:/Qt/5.13.0/android_x86_64", "-DQT_QMAKE_EXECUTABLE:STRING=C:/Qt/5.13.0/android_x86_64/bin/qmake.exe".
The CXX compiler identification is Clang 8.0.2
Check for working CXX compiler: C:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
Check for working CXX compiler: C:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- broken
CMake Error at C:/Android/android-sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeTestCXXCompiler.cmake:45 (message):
  The C++ compiler

    "C:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/Thorsten/AppData/Local/Temp/QtCreator-Zmienl/qtc-cmake-KUabkXqG/CMakeFiles/CMakeTmp

    Run Build Command:"C:/Android/android-sdk/cmake/3.10.2.4988404/bin/ninja.exe" "cmTC_622f7"
    [1/2] Building CXX object CMakeFiles/cmTC_622f7.dir/testCXXCompiler.cxx.obj
    [2/2] Linking CXX executable cmTC_622f7.exe
    FAILED: cmTC_622f7.exe 
    cmd.exe /C "cd . && C:\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe    CMakeFiles/cmTC_622f7.dir/testCXXCompiler.cxx.obj  -o cmTC_622f7.exe -Wl,--out-implib,libcmTC_622f7.dll.a -Wl,--major-image-version,0,--minor-image-version,0  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
    clang++.exe: error: unable to execute command: program not executable
    clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.




  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:8 (project)


Configuring incomplete, errors occurred!
See also "C:/Users/Thorsten/AppData/Local/Temp/QtCreator-Zmienl/qtc-cmake-KUabkXqG/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Thorsten/AppData/Local/Temp/QtCreator-Zmienl/qtc-cmake-KUabkXqG/CMakeFiles/CMakeError.log".
CMake Project parsing failed.
Run Code Online (Sandbox Code Playgroud)

我找到了几篇关于此问题的帖子,但大多数都没有得到答复或根本没有用。我发现很有帮助,所以我添加了

SET (CMAKE_C_COMPILER_WORKS 1)
SET (CMAKE_CXX_COMPILER_WORKS 1)
Run Code Online (Sandbox Code Playgroud)

在项目()之前。但现在我明白了

CMake Error in CMakeLists.txt:
  No known features for CXX compiler

  "Clang"

  version 8.0.2.


CMake Project parsing failed.
Run Code Online (Sandbox Code Playgroud)

到目前为止我还没有找到对此有用的东西。

我希望通过这种方式我能得到更多的帮助。

ps:我最近重新安装了我的操作系统(Windows 10),所以如果我忘记更新某些东西,它不会超过两个月。我让 QtCreator、Visual Studio 和 Android Studio 来安装工具链。

pps:该项目是QtCreator创建的新项目