Visual Studio 2015,带有libc ++和cmath问题的Android NDK [英] Visual Studio 2015, Android NDK with libc++ and cmath issues

查看:334
本文介绍了Visual Studio 2015,带有libc ++和cmath问题的Android NDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用新的Visual Studio 2015 Preview创建本机Android NDK项目并将STL更改为"LLVM libc ++静态库(c ++ _ static)"时,只需在默认的"main.cpp"文件中包括<cmath>,使用默认的Clang 3.4编译会导致以下问题:

When creating a native Android NDK project with the new Visual Studio 2015 Preview and changing the STL to "LLVM libc++ static library (c++_static)", simply including <cmath> in the default "main.cpp" file and compiling with the default Clang 3.4 causes the following issues:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Apps\android-ndk-r10\sources\cxx-stl\llvm-libc++\libcxx\include\cmath(652,8): error : no member named 'float_t' in the global namespace
1>  using ::float_t;
1>        ~~^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Apps\android-ndk-r10\sources\cxx-stl\llvm-libc++\libcxx\include\cmath(653,8): error : no member named 'double_t' in the global namespace
1>  using ::double_t;
1>        ~~^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Apps\android-ndk-r10\sources\cxx-stl\llvm-libc++\libcxx\include\cmath(680,85): error : use of undeclared identifier 'acosl'
1>  inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) _NOEXCEPT {return acosl(__x);}

...以及更多.

这在使用Eclipse时从未引起任何问题,所以我不确定我做错了什么还是默认项目是否有问题?

This never caused an issue when using Eclipse, so I'm not sure what I'm doing wrong or if there is an issue with the default project?

目前,我已经向Microsoft Connect添加了一个错误修正票证:

For now I've added a bugfix ticket to Microsoft Connect:

https://connect.microsoft.com/VisualStudio/feedback/details/1031464/compiling-ndk-project-when-includes-cmath-causes-issues-with-clang-and-libc

推荐答案

原因是存在于Android平台19及以下版本的<math.h>的这些typedef都用

The reason for this is that the <math.h> that exists for android platforms 19 and below has these typedefs enclosed by an

#if 0
#endif

块.对于这些平台,这些额外的定义位于

block. For these platforms, these extra defines are in

$(VS_NdkRoot)/sources/android/support/include

只需在Visual Studio的项目设置中包含此文件夹,即可成功编译.

Simply including this folder in Visual Studio's project settings leads to a successful compile.

顺便说一句,较新的NDK-10c中平台21的<math.h>文件看起来是固定的(因此您不需要包括support文件夹),但是Visual Studio 2015预览版将安装版本10.安装了带有10c的版本10,然后在项目资源管理器中获得了以目标平台21为目标的选项(尽管官方不支持).这样编译就可以了,尽管它针对的是平台21,但在解决此问题之前应该可以.

As an aside, the <math.h> file for platform 21 in the newer NDK-10c looks fixed (so you don't need to include the support folder), however the Visual Studio 2015 Preview installs version 10. When replacing the installed version 10 with 10c, we then get the option in the project explorer to target platform 21 (although officially unsupported). This compiles fine, and although it targets platform 21, should be ok until this issue is resolved.

这是相关的Android错误报告(实际上是Visual Studio问题,因为它应该在默认项目中包含此文件夹):

Here is the relevant Android bug report (it's actually a Visual Studio problem as it should include this folder in the default project):

https://code. google.com/p/android/issues/detail?id=79890&thanks=79890&ts=1416335194

使用更新的VS_NdkRoot宏更改了旧的NDKRoot宏.

Changed old NDKRoot macro with newer VS_NdkRoot macro.

这篇关于Visual Studio 2015,带有libc ++和cmath问题的Android NDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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