none
Visual Studio 2015, Android NDK with libc++ and cmath issues RRS feed

  • Question

  • 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> 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);}

    ...etc...

    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 default project?



    • Edited by Rajveer86 Sunday, November 16, 2014 10:34 PM
    Sunday, November 16, 2014 10:24 PM

Answers

  • This is a problem with Visual Studio. The relevant defines in the <math.h> file included in NDK-10 are enclosed by "#if 0" preprocessor commands, however these defines are found in

    $(NDKRoot)/sources/android/support/include.

    Simply including this folder in the Visual Studio project fixes this issue - this should be done by default by Visual Studio.

    Android bug report here, more info here.






    • Proposed as answer by May Wang - MSFT Wednesday, November 19, 2014 7:12 AM
    • Marked as answer by May Wang - MSFT Tuesday, November 25, 2014 2:57 AM
    • Edited by Rajveer86 Tuesday, November 25, 2014 10:40 AM
    Wednesday, November 19, 2014 12:51 AM

All replies

  • Hi,

    Thanks for posting here and paying attention to the new product.

    Firstly I have to say due to the VS2015 preview is not a formal release version, it is still in the process of collecting feedbacks, so welcome to raise any issue related through UserVoice, Connect, and Send-a-Smile which is described in this blog:

    Visual Studio 2015 Preview, Visual Studio Community 2013, Visual Studio 2013 Update 4, and More

    http://blogs.msdn.com/b/visualstudio/archive/2014/11/12/visual-studio-2015-preview-visual-studio-community-2013-visual-studio-2013-update-4-and-more.aspx

    And you can also check if there is any compatibility issue:

    Visual Studio 2015 Preview Compatibility

    In addition, you may also refer to this article which lists the fixed bugs and known issues for the Microsoft Visual Studio 2015 Preview.

    Visual Studio 2015 Preview fixed bugs and known issues

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 17, 2014 9:37 AM
  • Thanks for your reply, I've submitted a bug report via Connect:

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

    I initially posted here hoping there would be a workaround, but unfortunately it looks like I'll have to wait for this to be fixed. Still, I can't wait to be able to use Visual Studio to compile my NDK project.



    • Edited by Rajveer86 Monday, November 17, 2014 8:29 PM
    Monday, November 17, 2014 5:24 PM
  • Hi,

    Thanks for your feedback.

    I can understand your feeling completely, however currently we have to wait the issue to be fixed on the connect. Thanks for your patience and understanding.

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, November 18, 2014 8:52 AM
  • This is a problem with Visual Studio. The relevant defines in the <math.h> file included in NDK-10 are enclosed by "#if 0" preprocessor commands, however these defines are found in

    $(NDKRoot)/sources/android/support/include.

    Simply including this folder in the Visual Studio project fixes this issue - this should be done by default by Visual Studio.

    Android bug report here, more info here.






    • Proposed as answer by May Wang - MSFT Wednesday, November 19, 2014 7:12 AM
    • Marked as answer by May Wang - MSFT Tuesday, November 25, 2014 2:57 AM
    • Edited by Rajveer86 Tuesday, November 25, 2014 10:40 AM
    Wednesday, November 19, 2014 12:51 AM
  • Adding $(NDKRoot)/sources/android/support/include to includes made it so that the project could build with <cmath>

    However, adding double z = tan(1.0); to my code caused it to fail again, with an undefined reference error. I assume that the problem is that I need to link the object code for cmath. Does anyone know how to do this?

    Edit: Was able to figure it out. In Configuration Properties -> Linker -> All Options -> Library Dependencies, add ;m to the list.


    • Edited by Matthew137 Saturday, January 10, 2015 1:26 AM
    Thursday, January 8, 2015 12:25 AM