【问题标题】:Android NDK include of math.h gives "use of undeclared identifier" error包含 math.h 的 Android NDK 给出“使用未声明的标识符”错误
【发布时间】:2018-03-09 20:06:20
【问题描述】:

我的 Visual Studio 2017 社区版中有一个包含两种项目类型 .androidproj (Android) 和 .vcxproj (C++) 的解决方案。我在 C++ 部分使用android-ndk-r13b

自从从 Visual Studio 2017 Community Edition 版本 15.5.7 更新到 15.6.1 (release notes) 我遇到以下阻塞错误:

error : use of undeclared identifier 'acosl'

查看构建输出中的代表行:

In file included from C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b\sources\android\support\include\math.h:31:
C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b\sources\cxx-stl\llvm-libc++\include\math.h(661,91): error : use of undeclared identifier 'acosl'
inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);}

acosl 旁边也找不到所有其他数学函数。

不幸的是,这些帖子对我没有帮助:

任何提示我可以尝试什么?

更新

minSdkVersion 设置为 15。 Visual Studio 更新前编译的解决方案没有错误。

【问题讨论】:

  • 你的minSdkVersion 是什么? acosl 直到 android-21 才可用。
  • minSdkVersion 设置为 15。我想提一下在 Visual Studio 更新之前编译的完全相同的解决方案。

标签: android-ndk visual-studio-2017 clang


【解决方案1】:

在 15.6 中,他们似乎在 MSBuild 文件中引入了更改“C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Application Type\Android\3.0\Default .props”,其中包含一堆默认输入值(MSBuild 属性),用于 Visual Studio 的 Android 构建过程。

导致此问题的更改是 UseOfStl 的新默认值,现在是 c++_static,而在以前的版本中是 gnustl_static

如前所述,这只是一个默认值,因此您可以通过在受影响的 vcxproj 文件中显式设置正确的值(在这种情况下为 c++_static)来解决此问题。

最简单的方法是打开 vcxproj 的属性页面,并在“常规”页面中将“使用 STL”设置为“GNU STL 静态库 (gnustl_static)”,如屏幕截图所示。

请注意,此问题已在此处作为错误发布:https://developercommunity.visualstudio.com/content/problem/211533/visual-studio-update-156-breaks-c-android-app-buil.html

【讨论】:

  • 成功了。你知道gnustl_staticc++_static 关于math.h 有什么区别吗?
  • 请注意,gnustl 计划在 NDK r17/r18 中被弃用和删除。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-17
相关资源
最近更新 更多