编译Android NDK的C ++ 11源代码 [英] Compiling C++11 sources for Android NDK

查看:271
本文介绍了编译Android NDK的C ++ 11源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Windows上编译一些C ++ 11源代码与Android NDK,但没有太多的运气。请注意,我已经阅读了关于编译C ++ 11的一些其他问题,但他们没有帮助很多不幸的。

I'm trying to compile some C++11 sources with Android NDK on Windows, but without much luck. Please note, that I've read some other questions about compiling C++11, but they didn't help much unfortunately.

我已经下载了ADT软件包最新的NDK( android-ndk-r9b-windows-x86.zip )。

I've downloaded the ADT Bundle and latest NDK (android-ndk-r9b-windows-x86.zip).

这些是我的配置文件:

These are my configuration files:

Application.mk

APP_STL := gnustl_static
NDK_TOOLCHAIN_VERSION = 4.8
LOCAL_CPP_FEATURES += exceptions
LOCAL_CFLAGS += -std=c++11

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := procalc-core

LOCAL_SRC_FILES := pcc_arithmetics.cpp \
pcc_arithmetics_tools.cpp \
pcc_common.cpp \
pcc_core.cpp \
pcc_dms_tokenizer.cpp \
pcc_dynamic_numerics.cpp \
pcc_exceptions.cpp \
pcc_expressiontree.cpp \
pcc_expression_containers.cpp \
pcc_messages.cpp \
pcc_numerics.cpp \
pcc_resolvers.cpp \
pcc_syntaxtree.cpp \
pcc_tokenizer.cpp \
sm_Bignum.cpp \
sm_Math2D.cpp \
sm_MathNumerics.cpp \
ss_Streams.cpp

include $(BUILD_SHARED_LIBRARY)

Build命令

cd %AndroidProjects%ProCalc\jni\
D:\Android\ndk\ndk-build

pause

错误 />
这实际上是一个错误,但它显然不能识别新的C ++ 11关键字,例如 auto nullptr

D:/(path)/jni/pcc_arithmetics.cpp: In static member function 'static 
ProCalcCore::BaseNumeric* (* ProCalcCore::Arithmetics::GetFunctionMethod(std::string))
(const std::vector<const ProCalcCore::BaseNumeric*>&)': 
D:/(path)/jni/pcc_arithmetics.cpp:4077:11: error: 'nullptr' was not declared in 
this scope

return nullptr;
       ^

我做错了什么?

推荐答案

LOCAL_CPP_FEATURES += exceptions
LOCAL_CFLAGS += -std=c++11

应该进入Android.mk文件。或者,您可以将

Should go into Android.mk file. Alternatively, you could put

APP_CFLAGS += -std=c++11

到Application.mk中。您也可以使用 APP_CPPFLAGS ,以便您的项目中的C源代码(如果您选择添加它们)可以编译(C编译器不会喜欢 -std = c ++ 11 )。

into Application.mk. You can also use APP_CPPFLAGS instead, so that the C sources in your project (if you choose to add them) could compile (the C compiler will not like -std=c++11).

这篇关于编译Android NDK的C ++ 11源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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