7

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)

3 Answers 3

5

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
2

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
9
  • 1
    I added that. Here's the new error. In file included from /Users/geek/code/app/jni/app.h:20:0, from /Users/geek/code/app/jni/app.cpp:17: /android-14/arch-arm/usr/include/jni.h:592:13: note: the mangling of 'va_list' has changed in GCC 4.4 /Users/geek/code/app/jni/jni_egl_fence.cpp: In function 'void Java_com_android_gallery3d_photoeditor_FilterStack_nativeEglSetFenceAndWait(JNIEnv*, jobject)': /Users/geek/code/app/jni/app.cpp:31:72: error: 'eglCreateSyncKHR' was not declared in this scope
    – Taranfx
    Commented Aug 23, 2012 at 12:54
  • 1
    What the hell this means? I've no idea about c++. "the mangling of 'va_list' has changed in GCC 4.4"
    – Taranfx
    Commented Aug 23, 2012 at 12:55
  • 1
    That just looks like a warning. The error is "'eglCreateSyncKHR' was not declared in this scope." You need to include #include <EGL/egl.h> #include <EGL/eglext.h> wherever you're using EGL functions
    – Samuel
    Commented Aug 23, 2012 at 13:03
  • 2
    For more information about the warning see groups.google.com/forum/?fromgroups=#!topic/android-ndk/…
    – Samuel
    Commented Aug 23, 2012 at 13:06
  • See my app.cpp, they are included
    – Taranfx
    Commented Aug 23, 2012 at 13:15
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.