Issue in including EGL header file to native code

2,250 views
Skip to first unread message

Atul Prakash

unread,
Apr 27, 2011, 2:50:58 AM4/27/11
to android-ndk
Hello Friends,

I am trying to include <gl.h> & <egl.h> header files in my native .CPP
code in order to run OpenGL ES commands from my native code like
below:

#include <GLES/gl.h>
#ifndef ANDROID_NDK
#include <GLES/egl.h>
#endif /* !ANDROID_NDK */

I think <gl.h> header file is included in project successfully because
when I compile native code, I got no error regarding <gl.h> but EGL
header file i.e. <egl.h> is not included as I got errors like:

LWT@LWT-PC /cygdrive/c/myspace/test
$ ndk-build
Compile++ thumb : testing <= first.cpp
In file included from C:/myspace/test/jni/first.cpp:18:
C:/myspace/test/jni/importgl.h:12:22: error: GLES/egl.h: No such file
or directory
In file included from C:/myspace/test/jni/first.cpp:18:
C:/myspace/test/jni/importgl.h:42: error: ISO C++ forbids declaration
of 'EGLBoolean' with no type
C:/myspace/test/jni/importgl.h:42: warning: 'EGLBoolean' initialized
and declared 'extern'
In file included from C:/myspace/test/jni/first.cpp:18:
C:/myspace/test/jni/importgl.h:42: error: 'funcPtr_eglChooseConfig'
was not declared in this scope
- - - - - -
In file included from C:/myspace/test/jni/first.cpp:18:
C:/myspace/test/jni/importgl.h:54: error: 'funcPtr_eglTerminate' was
not declared in this scope
make: *** [/cygdrive/c/myspace/test/obj/local/armeabi/objs/testing/
first.o] Error 1
-------------------------------------------------------------------------------------------------------------------
I have also checked for <egl.h> header file in the "platforms" folder
of android-ndk-r5b. There are total 5 folders regarding the android
versions i.e. 3, 4, 5, 8 & 9. There is no file like <egl.h> except in
android-9 and it exists in EGL folder, instead of GLES folder.

I have also looked to San Angeles sample code it is successfully
including EGL header file with the same declaration as I am using i.e.
#include <GLES/egl.h>

Moreover, I have also specified local load libraries in Android.mk
file like:

LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog

I have no clue, what is missing in my code.

Thanks in advance.

Atul Prakash Singh


Message has been deleted

mic _

unread,
Apr 27, 2011, 3:25:36 AM4/27/11
to andro...@googlegroups.com
>>I have also looked to San Angeles sample code it is successfully including EGL header

It doesn't include egl.h, because that include is inside an #ifndef ANDROID_NDK.

You should look at the native-activity example, which uses EGL. And you might also want to consider whether you actually need EGL since it requires Android 2.3 or later.

/Michael



--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Atul Prakash

unread,
Apr 27, 2011, 4:43:31 AM4/27/11
to android-ndk
After having a look at native-activity sample, I tried it. I have also
added Appliction.mk & specified APP_PLATFORM := android-9. And now
instead of adding #inculde<GLES/egl.h>, I have written #include <EGL/
egl.h>

Then I compiled it from Cygwin, and this time it compiled
successfully, but when I run this project in eclipse, it crashes with
run time exception "java.lang.ExceptionInInitializerError".

My Android project is currently using sdk version 8 i.e. <uses-sdk
android:minSdkVersion="8" />

Is the .so file that is being generated after compiling native code is
not recognized by Android when I run this project from eclipse?

Looking forward for a piece of advice.

Rgds/ Atul Prakash Singh

On Apr 27, 12:25 pm, mic _ <micol...@gmail.com> wrote:
> >>I have also looked to San Angeles sample code it is successfully including
>
> EGL header
>
> It doesn't include egl.h, because that include is inside an #ifndef
> ANDROID_NDK.
>
> You should look at the native-activity example, which uses EGL. And you
> might also want to consider whether you actually need EGL since it requires
> Android 2.3 or later.
>
> /Michael
>

mic _

unread,
Apr 27, 2011, 5:15:14 AM4/27/11
to andro...@googlegroups.com
>>My Android project is currently using sdk version 8 i.e. <uses-sdk android:minSdkVersion="8" />

You should probably specify minSdkVersion 9 since the native code won't run with an API level lower than 9 anyway.

And you didn't mention what you're trying to run the code on. Is it a phone (which one?) or the emulator? If it's the emulator, are you using an AVD configured for 2.3 / API level 9, or something older?

/Michael
Reply all
Reply to author
Forward
0 new messages