android gl2ext.h,android ndk找不到 GLES/glext.h:

博客作者在使用Android NDK进行C++游戏开发时遇到#include 失败的问题,原因是系统调用了不包含glext.h的android-3库,而工程目标设置为android-4。通过删除android-3库并重新编译解决了问题。文章还介绍了Android NDK在不同版本中提供的库和API,如log.h、OpenGLES等,并提到了如何链接库和使用NDK的方法。
摘要由CSDN通过智能技术生成

android开发C++游戏时,可以#include ,但是#include 出错。

原因如下:

去ndk目录下查找glext.h

wulong@PC0514-48850 /cygdrive/d/hai_software/android/android-ndk-r4

$ find -name "glext.h"

./build/platforms/android-4/arch-arm/usr/include/GLES/glext.h

./build/platforms/android-5/arch-arm/usr/include/GLES/glext.h

./build/platforms/android-5/arch-x86/usr/include/GLES/glext.h

./build/platforms/android-8/arch-arm/usr/include/GLES/glext.h

./build/platforms/android-8/arch-x86/usr/include/GLES/glext.h

再查找log.h

$ find -name "log.h"

./build/platforms/android-3/arch-arm/usr/include/android/log.h

./build/platforms/android-4/arch-arm/usr/include/android/log.h

./build/platforms/android-5/arch-arm/usr/include/android/log.h

./build/platforms/android-5/arch-x86/usr/include/android/log.h

./build/platforms/android-8/arch-arm/usr/include/android/log.h

./build/platforms/android-8/arch-x86/usr/include/android/log.h对比后发现调用的是android-3的库,此包中不含有glext.h文件。在我们工程default.properties文件处 target=android-4。我已经指定了,但仍然调用android-3,费解,直接删除android-3文件夹。重新编译,这次指定android-4平台成功,程序编译通过。

为什么开始指定target=android-4无效?这个问题日后再查。

搜索到以下方法,尝试后无效,但是收藏一下。

转自:http://apps.hi.baidu.com/share/detail/47459727

http://blog.csdn.net/smfwuxiao/article/details/6590723

使用 Android NDK 的一般方法:

1、假如想要使用foo这个模块,先要 #include , 然后链接 /system/lib/libfoo.so 。

(在 Android.mk 文件中加入 LOCAL_LDLIBS := -lfoo)

ndk-build 会自动链接 C库、数学库、C++库

android-3 -> Official Android 1.5 system images

android-4 -> Official Android 1.6 system images

android-5 -> Official Android 2.0 system images

android-6 -> Official Android 2.0.1 system images

android-7 -> Official Android 2.1 system images

android-8 -> Official Android 2.2 system images

android-9 -> Official Android 2.3 system images

Android 1.5 以上的系统,下面这些库可用:

1、C库(这个C库包含多线程支持,所以不需要指定 -lpthread,也不需要指定 -lrt )

注意:内核头文件很没有稳定下来(今后可能变动),这些头文件是   和

2、数学库(也不需要指定 -lm)

3、C++库: 目前只有这些头文件可用。(不需要指定 -lstdc++ ,是自动链接的)

4、Android log:

   android系统的log功能

要用这个API,需要指定 LOCAL_LDLIBS := -llog

5、zlib库:

链接:  -lz   ( /system/lib/libz.so)

http://www.zlib.net/manual.html

6、动态连接器库:

这个库提供的函数例如: dlopen()/dlsym()/dlclose()

LOCAL_LDLIBS := -ldl ( /system/lib/libdl.so)

----------------------- 以上由 android-3提供 ---------------------------------

1、OpenGL ES 1.x 库

LOCAL_LDLIBS := -lGLESv1_CM.so( /system/lib/libGLESv1_CM.so)

  ( http://developer.android.com/guide/topics/manifest/uses-feature-element.html)

----------------------- 以上是 android-4 新增的NDK API -------------------------

1、OpenGL ES 2.0

LOCAL_LDLIBS := -lGLESv2.so  ( /system/lib/libGLESv2.so)

注意: 目前模拟器还不支持这个库

--------------------------以上是 android-5 新增的内容  ------------------------------

1、jnigraphics 库

一个小型的C语言库,提供对Java中的 bitmap 对象的操作。

包含:

链接: LOCAL_LDLIBS += -ljnigraphics

典型用法:

a) 用 AndroidBitmap_getInfo() 函数从位图句柄(从JNI得到)获得信息(宽度、高度、像素格式)

b) 用 AndroidBitmap_lockPixels() 对像素缓存上锁,即获得该缓存的指针。

c) 用C/C++ 对这个缓冲区进行读写

d) 用 AndroidBitmap_unlockPixels() 解锁

------------------------ 以上是 android-8 新增 -----------------------------

1、OpenSL ES 本地音频库

头文件: 和

链接: LOCAL_LDLIBS += -lOpenSLES (libOpenSLES.so)

----------------------- 以上是 android-9 新增的 -------------------------------

从android-9 开始,就可以完全用C/C++来写android程序了(完全脱离java)

但是,仍然没有脱离java虚拟机,许多东西还是需要通过jni来访问 (参考 docs/NATIVE-ACTIVITY.html )

头文件:

1、活动(Activity)生命期的管理

头文件:       

2、监听事件和传感器

头文件:       

3、窗口管理(包括对像素缓存加锁、解锁)

头文件:

  对嵌入 apk中的资源(或OBB文件)进行只读的、直接访问。

OBB(Opaque Binary Blob)文件,新特性,允许把较大的数据放在apk之外(对于游戏程序有用)

上面提到的头文件在 "libandroid.so" 共享库中。

链接方法:  LOCAL_LDLIBS += -landroid

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值