使用 ADT/Eclipse 为 NDK 设置 C++11 (std::thread) [英] Setting up C++11 (std::thread) for NDK with ADT/Eclipse

查看:62
本文介绍了使用 ADT/Eclipse 为 NDK 设置 C++11 (std::thread)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用 C++11.我正在开发一个 android 项目,我想使用 std::mutex.与 OpenCV 一起但无论我做什么,我似乎都无法修复 Type 'mutex' could not be resolved错误.

I have been trying to use C++11. I am developing an android project and i want to use std::mutex. Along with OpenCV But no matter what I do, I just cant seem to fix the Type 'mutex' could not be resolved error.

我尝试按照我在 SO 和其他地方找到的教程进行操作.LINK1 LINK2 LINK3LINK4

I have tried following the tutorials i found on SO and other places. LINK1 LINK2 LINK3LINK4

  1. ADT v22.3.0-887826
  2. 已安装的 C/C++ 编译器 (CDT)

看了这么多教程,现在变得一团糟.所以我将解释我当前的设置

Following so many tutorials, it has become a real mess now. So I will explain my current settings

  • 项目 > 属性 > C/C++ 构建 > 工具链编辑器
    • 当前的工具链是跨 GCC"
    • 当前的 Builder 是Android Builder"

    项目 > 属性 > C/C++ 构建 > 发现选项

    Project > Properties > C/C++ Build > Discovery Options

    • 编译器调用命令是gcc"
    • 编译器调用参数是 -E -P -v -dD "${plugin_state_location}/specs.c -std=c++11"

    项目 > C/C++ 常规 > 路径和符号 > # 符号选项卡

    Project > C/C++ General > Paths and Symbols > # Symbols tab

    • 符号 = __cplusplus 和值 = 1

    在我的 Application.mk 文件中,我有以下内容

    In my Application.mk file I have the following

    APP_STL := gnustl_static
    APP_USE_CPP0X := true
    APP_CPPFLAGS := -std=c++11 -frtti -fexceptions
    APP_ABI := armeabi-v7a
    APP_PLATFORM := android-8
    

    我尝试将 cplusplus 符号的值更改为 201103L并用空值尝试了 __GXX_EXPERIMENTAL_CXX0X

    但似乎没有任何效果,我做错了什么??

    But nothing seems to work, What am I doing wrong??

    感谢任何帮助!

    推荐答案

    std::thread 的支持有点特殊.例如,在 这篇文章中解决了这个问题由冰龙.文章确实很短,但一句话就能概括:

    Support for std::thread is a bit special. The issue is addressed, for example, in this article by Binglong. The article is really short, but it can be summarized in one sentence:

    如果您想 #include <thread>#include <mutex>,则不能使用(默认)gcc 4.6 工具链.

    You cannot use the (default) gcc 4.6 toolchain if you want to #include <thread> or #include <mutex>.

    所以,请将 NDK_TOOLCHAIN_VERSION=4.8NDK_TOOLCHAIN_VERSION=clang 添加到您的 Application.mk.

    So, please add NDK_TOOLCHAIN_VERSION=4.8 or NDK_TOOLCHAIN_VERSION=clang to your Application.mk.

    要让 ADT 正确重建其 Index,请参阅 Android NDK 构建,方法无法解析Eclipse 编译成功但仍然给出语义错误.

    For ADT to rebuild its Index correctly, see Android NDK build, Method could not be resolved or Eclipse compiles successfully but still gives semantic errors.

    这篇关于使用 ADT/Eclipse 为 NDK 设置 C++11 (std::thread)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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