巴扎黑酋长 2018-04-27 07:12 采纳率: 0%
浏览 1589
已结题

QT安卓开发在调试时遇到错误

请教各位Qt大神,在运行Qt编谢程序时,总是不成功,会出现如下错误:
图片说明
详细错误说是:
C:\Android\android-ndk-r10e\sources\cxx-stl\gnu-libstdc++\4.9\include\cstddef:44: error: bits/c++config.h: No such file or directory
#include ^
下面是我的环境变量,之前看网上有人说环境变量有问题,但是我看我的应该没错啊?
图片说明
使用的QT版本为5.6.1,AndroidNDK为r10e。

  • 写回答

3条回答

  • 默默悟问 2018-04-27 07:39
    关注

    创建 CMake 构建脚本
    如果没有一个 CMake 构建脚本,你需要自己手动创建一个,并添加一些合适的 CMake 命令。CMake 构建脚本是一个空白的文本文档(后缀为 .txt 的文件),名字必须为 CMakeLists.txt。

    注意:如果你的项目使用了 ndk-build,你就不需要创建 CMake 构建脚本,只需要提供一个路径链,将你的 Android.mk 文件链接到 Gradle 中即可。

    将一个空白的文本文档变成一个 CMake 构建脚本,你需要这么做:

    打开 IDE 左边的 Project 面板,选择 Project 视图。
    在你的 module 根目录下,右键,选择 New > File。
    输入 “CMakeLists.txt” 作为文件名,并点击 OK。
    现在,你可以添加 CMake 命令来配置你的构建脚本了。为了让 CMake 将源代码(native source code)编译成 native library。需要在编译文件中添加 cmake_minimum_required() 和 add_library() 命令:

    复制代码
    1 # Sets the minimum version of CMake required to build your native library.
    2 # This ensures that a certain set of CMake features is available to
    3 # your build.
    4
    5 cmake_minimum_required(VERSION 3.4.1)
    6
    7 # Specifies a library name, specifies whether the library is STATIC or
    8 # SHARED, and provides relative paths to the source code. You can
    9 # define multiple libraries by adding multiple add.library() commands,
    10 # and CMake builds them for you. When you build your app, Gradle
    11 # automatically packages shared libraries with your APK.
    12
    13 add_library( # Specifies the name of the library.
    14 native-lib
    15
    16 # Sets the library as a shared library.
    17 SHARED
    18
    19 # Provides a relative path to your source file(s).
    20 src/main/cpp/native-lib.cpp )
    复制代码

    当你使用 add_library(),将一个源文件(source file)或库添加到你的 CMake 构建脚本,同步你的项目,然后你会发现 Android studio 将关联的头文件也显示了处理。然而,为了让 CMake 在编译时期能定位到你的头文件,你需要在 CMake 构建脚本中添加 include_directories() 命令,并指定头文件路径:

    1 add_library(...)
    2
    3 # Specifies a path to native header files.
    4 include_directories(src/main/cpp/include/)

    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码