Android Studio NDK错误,尽管存在,但找不到GLES3/gl3.h [英] Android Studio NDK error, couldn't find GLES3/gl3.h although it exist

查看:752
本文介绍了Android Studio NDK错误,尽管存在,但找不到GLES3/gl3.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在使用NDK和OpenGL ES 3.0的Android Studio上制作一个应用. GLES3/gl3.h>,我键入时IDE会自动完成,我认为这是一个标志,意味着IDE可以找到它 但是,在生成项目时,出现错误:错误:(22,10)致命错误:找不到'GLES3/gl3.h'文件" .我在项目结构"中检查了NDK路径:

I'm trying to make an app on Android Studio that use the NDK and OpenGL ES 3.0.When I #include < GLES3/gl3.h >, the IDE has auto completion as I typing, I think it's a sign meaning that the IDE can find it However, I got the error : "Error:(22, 10) fatal error: 'GLES3/gl3.h' file not found" when I build the project. I check the NDK path in Project Structure, which is :

sdk\ndk-bundle\platforms\android-21\arch-arm64\usr\include\GLES3

是正确的,并且GLES3/gl3.h确实存在.

it's correct and the GLES3/gl3.h does exist there.

我已经用GLESv3声明了我的CMakeList:

I have declared my CMakeList with GLESv3 already:

cmake_minimum_required(VERSION 3.4.1)

# now build app's shared lib
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")

add_library(gl3jni SHARED
            gl_code.cpp
            stb_image.cpp
            )

# add lib dependencies
target_link_libraries(gl3jni
                      android
                      log 
                      EGL
                      GLESv3)

我还通过以下方式在Manifest.xml中声明了OpenGL ES版本:

I also declare the OpenGL ES version in the Manifest.xml with:

<uses-feature android:glEsVersion="0x00030000" android:required="true"/>

我在做什么错了?

推荐答案

Android ndk-bundle自api 18起就具有openglES3,但位于arm平台中.

Android ndk-bundle has openglES3 since api 18, but in arm platform.

我的意思是,如果要在armV8_64中编译项目,则必须将min sdk设置为21.但是,如果要使用armeabi或armeabiV7,则最小api将为18.

I mean, if you are going to compile your project in armV8_64, you must set your min sdk to 21. But if you are going to use armeabi or armeabiV7 the minimum api will be 18.

因此,请根据您在 app/build.gradle 文件中的首选项更改minSDK依赖项.

So change your minSDK dependig on your preferences in the app/build.gradle file.

我建议您定义API 21并定义产品风味以支持所有体系结构,除了可以进行其他3rdparty库链接之外,代码应类似于以下内容:

I suggest you to define the API 21 and define your product flavours to support for all architectures, besides you can make other 3rdparty library linkings, the code should be something like this:

android.productFlavors {
        // for detailed abiFilter descriptions, refer to "Supported ABIs" @
        // https://developer.android.com/ndk/guides/abis.html#sa
        create("arm") {
            ndk.abiFilters.add("armeabi")
            ndk.ldFlags.add("-L${file(''your_libraries_path'')}".toString())
            ndk.ldLibs.addAll(["your_armeabi_library"])
        }
        create("arm7") {
            ndk.abiFilters.add("armeabi-v7a")
            ndk.ldFlags.add("-L${file('your_libraries_path')}".toString())
            ndk.ldLibs.addAll(["your_armv7_library"])
        }
        create("arm8") {
            ndk.abiFilters.add("arm64-v8a")
            ndk.ldFlags.add("-L${file(''your_libraries_path')}".toString())
            ndk.ldLibs.addAll(["your_armv8_library"])
        }
}

此gradle代码来自gradle 0.8.3实验性插件,因此,如果您没有此版本,则需要进行一些更改以适合您的gradle版本.

This gradle code is from the gradle 0.8.3 experimental plugin, so if you have not this version, you need to make some changes to fit into your gradle version.

这篇关于Android Studio NDK错误,尽管存在,但找不到GLES3/gl3.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆