Search code examples
androidc++android-ndkandroid-sdk-tools

Android NDK cannot find -lGLESv


I am getting the following errors when I try to perform an NDK build, can anyone help me please?

I did the setup instruction exactly like what are written in "Beginning Android C++ Game Development". every step except the 9th:

"Click the NativeActivity node in the Application Nodes window and click Add once more. Enter the Name as android.app.lib_name and the Value as the LOCAL_MODULE name, which can be found in the Android.mk file in the project’s jni folder."

Errors :

10:44:23 ** Incremental Build of configuration Default for project HelloDroid ** "C:\ndk\ndk-build.cmd" all Android NDK: WARNING:jni/Android.mk:HelloDroid-Test: non-system libraries in linker flags: -lGLESv Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES Android NDK:
or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the Android NDK: current module [armeabi] SharedLibrary : libHelloDroid-Test.so C:/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lGLESv collect2: ld returned 1 exit status make.exe: * [obj/local/armeabi/libHelloDroid-Test.so] Error 1

10:44:23 Build Finished (took 226ms)


Solution

  • I found the problem. I just needed to edit the Android.mk it now looks like this:

    LOCAL_PATH := $(call my-dir)
    
    include $(CLEAR_VARS)
    
    LOCAL_MODULE    := hellodroid
    LOCAL_SRC_FILES := hellodroid.cpp
    LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2
    LOCAL_STATIC_LIBRARIES := android_native_app_glue 
    
    include $(BUILD_SHARED_LIBRARY)
    
    $(call import-module, android/native_app_glue)