Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use GLM 0.9.6 with Android NDK #284

Closed
Donorhan opened this issue Dec 8, 2014 · 17 comments
Closed

Unable to use GLM 0.9.6 with Android NDK #284

Donorhan opened this issue Dec 8, 2014 · 17 comments
Assignees
Labels
Milestone

Comments

@Donorhan
Copy link

Donorhan commented Dec 8, 2014

I'm updating GLM from 0.9.5.4 to 0.9.6.0 and something is wrong during the Android NDK compilation: I've got errors with std functions not founds:

glm/gtc/../detail/func_common.inl:229:16: error: 'std::trunc' has not been declared using ::std::trunc;

Same error with "std::round", "std::asinh", "std::atanh", "std::acosh", …. Everything was working well before the last update. (I'm using gcc 4.9 and compile with --std=c++11)

Thanks!

Groovounet pushed a commit that referenced this issue Dec 8, 2014
@Groovounet Groovounet added the bug label Dec 8, 2014
@Groovounet Groovounet added this to the GLM 0.9.6 milestone Dec 8, 2014
@Groovounet Groovounet self-assigned this Dec 8, 2014
@Groovounet
Copy link
Member

This issue should be fixed GLM 0.9.6 branch for 0.9.6.1 release but your confirmation would be helpful.

Thanks for contributing,
Christophe

@Donorhan
Copy link
Author

Donorhan commented Dec 8, 2014

Sadly, the problem is always here :/

if GLM_COMPILER & GLM_COMPILER_CLANG
Is false

In the else state:

GLM_LANG & GLM_LANG_CXX0X_FLAG
Is true

GLM_COMPILER_VC
Is false

Edit: So, GLM_HAS_CXX11_STL is false

@Groovounet
Copy link
Member

GLM_HAS_CXX11_STL is supposed to be false actually.

If the C++11 STL was supported, then the functions you mentioned should be available.

I am going to modify the changes so that it only excludes Android as it seems to be specific to that platform. GCC 4.8.1 has not issue with this on Windows.

Thanks,
Christophe

@Donorhan
Copy link
Author

Donorhan commented Dec 9, 2014

I'm sorry but the error is still here :s. I've tried to switch to the previous version (0.9.5.4) and everything work fine.

I don't know if that can help, but I'm using Android NDK R10D (same result with R10C) and his default toolchain, I've tried with custom toolchain too: same errors.

@Groovounet
Copy link
Member

What the value of GLM_HAS_CXX11_STL? It should be false.
If it false, then std::round, std::asinh, etc. are not going to be used. so the error should at least not be the same.

Also, are you sure you are using GCC?

@Donorhan
Copy link
Author

Donorhan commented Dec 9, 2014

First part

I'm using Android's default toolchain so yes, but to be sure I've tried to do that: (with CMake)

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
     message("Clang")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
     message("gcc")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
      message("Intel c++")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
      message("Msvc")
endif()

Output print "gcc".

I've added a condition to show GLM_HAS_CXX11_STL's value too:

#if GLM_HAS_CXX11_STL
        #error "Should crash here"
#endif

Compilation continue so GLM_HAS_CXX11_STL is false.

Second part

So, I've tried with Android NDK sample "native-activity", here are the results with the line "std::cout << "acosh(0.5) = " << std::acosh(0.5) << '\n';":

GCC 4.9/gnustl_static AND GCC 4.9/stlport_static:

error: 'acosh' is not a member of 'std'

Clang/gnustl_static AND Clang/stlport_static:

error: no member named 'acosh' in namespace 'std'; did you mean simply 'acosh'?

c++_static (NDK error):

atomic:922: error: undefined reference to '__atomic_fetch_add_4'

@Groovounet
Copy link
Member

Regarding the second part, when GLM_HAS_CXX11_STL GLM is not using std::acosh, std::round, etc.
That's the point of GLM_HAS_CXX11_STL.

If you look at glm/detail/func_common.inl:229:16, you will see that using ::std::round; is called only if GLM_HAS_CXX11_STL is true.

@Donorhan
Copy link
Author

Donorhan commented Dec 9, 2014

Oh yes indeed!

The program don't go in the condition, so GLM_HAS_CXX11_STL is ok. Look like the problem is not from here but from the condition:

#if GLM_LANG & GLM_LANG_CXX11_FLAG

May be the condition should use "GLM_HAS_CXX11_STL"?

Files with the problem:

  • func_trigonometric.inl:166:14
  • func_trigonometric.inl:185:14
  • func_trigonometric.inl:206:14
  • func_exponential.inl:43:14

@Groovounet
Copy link
Member

Ah ok, so the errors were different. Yes, I think the issue is here, I'll fix it.

@Groovounet Groovounet reopened this Dec 9, 2014
Groovounet pushed a commit that referenced this issue Dec 9, 2014
@Groovounet
Copy link
Member

I have committed the changes so hopefully thinks will be better this time around.

Thanks,
Christophe

@Donorhan
Copy link
Author

Donorhan commented Dec 9, 2014

Everything works fine now!

Thanks a lot,
Dono

@Groovounet
Copy link
Member

Awesome and welcome!

@Donorhan
Copy link
Author

Sorry to say that, but the problem is back with the last version (GLM 0.9.6.2) :/

Edit: "func_exponential.inl:43:14: error: 'std::log2' has not been declared using std::log2;"

@Groovounet
Copy link
Member

Ahhh, I think I understand the issue...

#if GLM_PLATFORM != GLM_PLATFORM_ANDROID
#   define GLM_HAS_CXX11_STL 0
#elif GLM_COMPILER & (GLM_COMPILER_LLVM | GLM_COMPILER_APPLE_CLANG)
#   define GLM_HAS_CXX11_STL __has_include(<__config>)
#else
#   define GLM_HAS_CXX11_STL ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && \
        ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \
        ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))
#endif

Damn! Fixed with #if GLM_PLATFORM == GLM_PLATFORM_ANDROID

@Donorhan
Copy link
Author

Indeed! Everything is ok now :D.

Thanks!

@richardeakin
Copy link

FWIW, I found a stackoverflow post that sheds some light on the android / C++11 STL math library problem:

http://stackoverflow.com/questions/22922961/c11-cmath-functions-not-in-std-namespace-for-android-ndk-w-gcc-4-8-or-clang-3

@jandoerntlein
Copy link

Problem reoccurs in 0.9.7.3. There is no "GLM_PLATFORM_ANDROID" check in the file "setup.hpp" anymore. Was the patch intentionally removed from later versions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants