NDK OpenGL undefined link to glVertexPointer

When compiling the following C code with ndk-build in Terminal (I am running Ubuntu):

#include <jni.h>

#include <GLES/gl.h>
#include <GLES/glext.h>

#include "org_opengldrawinjni_DrawinJNI.h"


JNIEXPORT void JNICALL Java_org_opengldrawinjni_DrawinJNI_Draw
  (JNIEnv *envptr, jobject jobj)
{
 GLfloat vertices[] =
  { 1.0, 0.0, 0.0,
    1.0, 1.0, 0.0,
    0.0, 0.0, 0.0
  };
 GLubyte indices[] = { 0, 1, 2 };
 glVertexPointer(3, GL_FLOAT, 0, vertices);
 glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, indices);
}

with this Android.mk file:

   LOCAL_PATH := $(call my-dir)

   include $(CLEAR_VARS)

   LOCAL_MODULE    := OpenGLJNI
   LOCAL_SRC_FILES := org_opengldrawinjni_DrawinJNI.c
   LOCAL_LDLIBS := -llog -lGLESv1_CM.so

   include $(BUILD_SHARED_LIBRARY)

I get an error, undefined link to glVertexPointer. I wonder why, since I believe that I correctly included the headers and linked the libraries in Android.mk

/home/thomas/Documents/LinuxProgramming/EclipseWorkspace/OpenGLDrawinginJNI/obj/local/armeabi/objs/OpenGLJNI/org_opengldrawinjni_DrawinJNI.o: In function `Java_org_opengldrawinjni_DrawinJNI_Draw':
/home/thomas/Documents/LinuxProgramming/EclipseWorkspace/OpenGLDrawinginJNI/jni/org_opengldrawinjni_DrawinJNI.c:33: undefined reference to `glVertexPointer'
collect2: ld returned 1 exit status
make: *** [/home/thomas/Documents/LinuxProgramming/EclipseWorkspace/OpenGLDrawinginJNI/obj/local/armeabi/libOpenGLJNI.so] Error 1

Thank!

+3
source share
1 answer

I can't think of anything bad, but when I checked my makefile there is one difference. Since I am not good at compilers, I don’t know if this is really important:

LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog

Dynamic Linker Library:

dlopen()/dlsym()/dlclose() , Android . /system/lib/libdl.so :

LOCAL_LDLIBS: = -ldl

,

+7

Source: https://habr.com/ru/post/1775773/


All Articles