I am currently trying to port my OpenGL application to Android and am stuck on how to import and build GLM http://glm.g-truc.net/ properly. I have no trouble using GLM in standa
Follow this solution if you are using Android Studio.
First, download OpenGL Mathematics library here
Second, extract and copy folder "../glm/glm" to your project location at "../app/src/main/cpp"
Third, on CMakeList.txt, add the following:
# Import the CMakeLists.txt for the glm library
add_subdirectory(glm) # if your CMakeLists is at '../cpp'
# add_subdirectory(src/main/cpp/glm) # if your CMakeLists is at '../app'
# add lib dependencies
target_link_libraries(
# Specifies the target library.
native-lib
# Links the target library to the log library included in the NDK.
GLESv2
glm)
Fourth, on 'buidl.griddle' (Mobile App), make sure you have right path to your CMakeList
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
}
}
Fifth, include glm headers to your source file:
// open GL libs
#include
#include
#include
#include
#include
#include
Sample is available at android-ndk, see Android Endless Tunnel Game