在终端中使用ndk-build编译以下C代码时(我正在运行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);}
使用此AndroID.mk文件:
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 statusmake: *** [/home/thomas/documents/linuxProgramming/EclipseWorkspace/OpenGLDrawinginJNI/Obj/local/armeabi/libOpenGLJNI.so] Error 1
谢谢!
解决方法:
我想不出有什么不对,但是当我查看我的make文件时,有一点不同.
由于我对编译器不熟悉,我不知道它是否相关:
LOCAL_LDliBS:= – lGLESv1_CM -ldl -llog
Dynamic linker library:
is available and can be used
to use the dlopen()/dlsym()/dlclose()
functions provIDed by the AndroID
dynamic linker. You will need to link
against /system/lib/libdl.so with:LOCAL_LDliBS := -ldl
希望能帮助到你
总结以上是内存溢出为你收集整理的android – NDK OpenGL undefined对glVertexPointer的引用全部内容,希望文章能够帮你解决android – NDK OpenGL undefined对glVertexPointer的引用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)