3
編譯時使用NDK建造在碼頭下面的C代碼(我運行Ubuntu):與此Android.mk文件NDK的OpenGL未定義參考glVertexPointer
#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);
}
:
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)
我得到一個錯誤,未定義引用glVertexPointer。我想知道爲什麼,因爲我相信我正確地包含了頭文件並鏈接了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
謝謝!
它沒有爲我工作。我都做了同樣的結果和錯誤。 – 2014-10-08 15:36:44