Taranfx
Taranfx

Reputation: 10437

Compiling with NDK gives error for successfully included header files

My app.cpp:

#include "app.h"


#include <EGL/egl.h>
#include <EGL/eglext.h>

void
Java_com_geek_hello_FilterStack_nativeEglSetFenceAndWait(JNIEnv* env, jobject thiz) {
  EGLDisplay display = eglGetCurrentDisplay();

  // Create a egl fence and wait for egl to return it.
  // Additional reference on egl fence sync can be found in:
  // http://www.khronos.org/registry/vg/extensions/KHR/EGL_KHR_fence_sync.txt
  EGLSyncKHR fence = eglCreateSyncKHR(display, EGL_SYNC_FENCE_KHR, NULL);
  if (fence == EGL_NO_SYNC_KHR) {
    return;
  }
  ...

When I run ndk-build, it fails finding methods present in egl.h and .so is not created. Here's the log:

app.cpp:31:72: error: 'eglCreateSyncKHR' was not declared in this scope 

followed by all KHR methods that belong to

Here's Android.mk

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

#LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES
LOCAL_CFLAGS = -Wno-psabi

LOCAL_SRC_FILES := app.cpp

#LOCAL_SHARED_LIBRARIES := libcutils libEGL

LOCAL_MODULE_TAGS := optional

LOCAL_MODULE := libapp
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2

include $(BUILD_SHARED_LIBRARY)

Upvotes: 7

Views: 4985

Answers (3)

Ankitkumar Makwana
Ankitkumar Makwana

Reputation: 3485

i think you should follow this steps for more understanding steps

and before make bulid pls make sour

  • project path untill jni folde > and ndk path untill ndk-build ex D:\New_Wok_2\Firstndk\jni>c:\android-ndk-r8\ndk-build and clean your project

Upvotes: 0

kelnos
kelnos

Reputation: 878

You need to add:

#define EGL_EGLEXT_PROTOTYPES

before your #include lines (well, specifically before including EGL/eglext.h).

Also (and it looks like you're already doing this), you need to be building against at least API 14, since that's the first API level exposing this function in the public API.

EDIT: or just uncomment the line in your Android.mk that reads:

#LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES

Upvotes: 5

Samuel
Samuel

Reputation: 17171

Try following all the steps in:

http://en.wikibooks.org/wiki/OpenGL_Programming/Android_GLUT_Wrapper

From the log that you provided, the build can't find the EGL library, so I think you need the line

LOCAL_LDLIBS    := -llog -landroid -lEGL -lGLESv2

in your Android.mk. And make sure your Application.mk includes:

APP_STL := gnustl_static
APP_PLATFORM := android-9

Upvotes: 2

Related Questions