Include GLES31 in Android NDK

381 views Asked by At

I have followed the android-ndk/gles3jni example where they include gles3. But I still get undefined reference to gl* functions. My cmmakelist:

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -Wall")

add_library(gles3jni SHARED
            src/main/cpp/File.c
            )

# add lib dependencies
target_link_libraries(gles3jni
                      GLESv3
                      android
                      log
                      EGL
                      m)

Within my gradle build:

ndk {
    abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a'
}
externalNativeBuild {
    cmake {
        arguments "-DANDROID_PLATFORM_LEVEL=21",
                '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static'
    }
}

I include #include in my File.c.

1

There are 1 answers

1
Adrian On

Are you setting the CMakeLists.txt location in the build.gradle file? Everything you have is the same I have in my project but in the build.gradle file I include the CMakeLists.txt location.

externalNativeBuild {
    cmake {
        path "CMakeLists.txt"
    }
}