1

我正在为 Android 构建一个 3d 模型查看器应用程序。模型的显示和查看是通过 OpenGL 用 C++ 编写的,我正在使用 Android NDK 将其与 android 应用程序相结合。但是,当我尝试部署应用程序时,会遇到许多处理 OpenGL 代码的错误,例如:

/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/GLES2/gl2.h:501: error: expected constructor, destructor, or type conversion before 'void'
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/GLES2/gl2.h:502: error: expected constructor, destructor, or type conversion before 'void'
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/GLES2/gl2.h:503: error: expected constructor, destructor, or type conversion before 'void'
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/GLES2/gl2.h:504: error: expected constructor, destructor, or type conversion before 'void'
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/GLES2/gl2.h:505: error: expected constructor, destructor, or type conversion before 'void'

并且:

/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/gfx.cpp:66: error: 'glFrontFace' was not declared in this scope
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/gfx.cpp:67: error: 'glClearStencil' was not declared in this scope
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/gfx.cpp:68: error: 'glStencilMask' was not declared in this scope
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/gfx.cpp:70: error: 'glClearColor' was not declared in this scope
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/gfx.cpp:72: error: 'glClear' was not declared in this scope
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/gfx.cpp:76: error: 'glBindVertexArrayOES' was not declared in this scope
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/gfx.cpp:76: error: 'PFNGLBINDVERTEXARRAYOESPROC' was not declared in this scope
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/gfx.cpp:76: error: expected ';' before 'eglGetProcAddress'
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/gfx.cpp:77: error: 'glGenVertexArraysOES' was not declared in this scope
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/gfx.cpp:77: error: 'PFNGLGENVERTEXARRAYSOESPROC' was not declared in this scope
/Users/Preddy/Downloads/9781119975915/SDK/_chapter3-2/Android//jni/../../../common/gfx.cpp:77: error: expected ';' before 'eglGetProcAddress'

我显然在这里的设置中遗漏了一些东西。我正在使用 Sequoyah(用于编译和调试本机代码)和 NDK 版本。r5b(因为 Sequoyah 无法识别更高版本)。欢迎任何建议,我开始绝望。

编辑:Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE := openal
SRC_FILES := $(wildcard $(LOCAL_PATH)/../../../common/openal/*.c)
SRC_FILES := $(SRC_FILES:$(LOCAL_PATH)/%=%) 
LOCAL_SRC_FILES = $(SRC_FILES)
LOCAL_LDLIBS = -llog
LOCAL_CFLAGS := -O3 -mno-thumb
LOCAL_CPPFLAGS := -O3 -mno-thumb
include $(BUILD_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE   := templateApp
LOCAL_CFLAGS   := -O3 -mno-thumb 
LOCAL_CPPFLAGS := $(LOCAL_CFLAGS)
LOCAL_C_INCLUDES = $(LOCAL_PATH)/../../../common/openal/
SRC_FILES := $(wildcard $(LOCAL_PATH)/../../*.cpp)
SRC_FILES += $(wildcard $(LOCAL_PATH)/../../../common/*.cpp)
SRC_FILES += $(wildcard $(LOCAL_PATH)/../../../common/bullet/*.cpp)
SRC_FILES += $(wildcard $(LOCAL_PATH)/../../../common/ttf/*.cpp)
SRC_FILES += $(wildcard $(LOCAL_PATH)/../../../common/nvtristrip/*.cpp)
SRC_FILES += $(wildcard $(LOCAL_PATH)/../../../common/png/*.c)
SRC_FILES += $(wildcard $(LOCAL_PATH)/../../../common/zlib/*.c)
SRC_FILES += $(wildcard $(LOCAL_PATH)/../../../common/detour/*.cpp)
SRC_FILES += $(wildcard $(LOCAL_PATH)/../../../common/recast/*.cpp)
SRC_FILES += $(wildcard $(LOCAL_PATH)/../../../common/vorbis/*.c)
SRC_FILES := $(SRC_FILES:$(LOCAL_PATH)/%=%)
LOCAL_SRC_FILES := $(SRC_FILES)
LOCAL_SHARED_LIBRARIES := libopenal
LOCAL_LDLIBS := -L$(LOCAL_PATH)/../libs/armeabi
LOCAL_LDLIBS += -lz -lm -ldl -lGLESv2 -lEGL -llog -lopenal
LOCAL_CFLAGS := -O3 -mno-thumb -Wno-write-strings
LOCAL_CPPFLAGS := -O3 -mno-thumb -Wno-write-strings
include $(BUILD_SHARED_LIBRARY)
4

0 回答 0