Android Studio 致命错误:CL/cl.h No such file or directory [英] Android Studio fatal error: CL/cl.h No such file or directory

查看:52
本文介绍了Android Studio 致命错误:CL/cl.h No such file or directory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Android Studio 中构建 openCL 程序并不断遇到以下问题:

I am trying to build an openCL program in Android Studio and keep running into the following issue:

Android Studio fatal error: CL/cl.h No such file or directory

我一直在寻找,一切都是视觉工作室"的解决方案.

I have been searching and everything is a solution for "visual studio".

我认为如果我们有专门针对 Android Studio 和此错误列出的解决方案可能会有所帮助.

I thought it may be helpful if we had a solution listed specifically for Android Studio and this error.

任何想法如何解决这个问题?我看到参考 here 似乎正在从命令行运行 gcc.我希望这仅在 Android Studio 中工作.

Any ideas how to fix this? I see references here appears to be running gcc from command line. I want this to work just from Android Studio.

推荐答案

OpenCL 不是 Android 的一部分,因此您找不到 cl.h.从这里下载必要的 CL 头文件:https://www.khronos.org/registry/cl/

OpenCL is not part of Android, so you cannot find cl.h. Download necessary CL header files from here: https://www.khronos.org/registry/cl/

下载正确版本的 cl.h(与您使用的 CL 版本相同,例如 CL 1.1).

Download the cl.h with the correct version (same as the CL version you are using, for example, CL 1.1).

在您的 OpenCL 程序中包含头文件,然后您就可以开始了.

Include the header files in your OpenCL program, then you are good to go.

2015 年 4 月 18 日

要包含 OpenCL 头文件,您可以执行以下操作:

To include the OpenCL header files, you can do the following:

#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/opencl.h>
#endif

但是如果您的程序是纯 CL 代码(没有 CL-GL 互操作性),那么简单地包含 CL/cl.h 也应该可行:

But if you program is a purely CL code (without CL-GL interoperability), simply including CL/cl.h should also work:

#include <CL/cl.h>

执行此操作后,您应该将包含 CL 文件夹的文件夹添加到您的 makefile 中的包含路径中.(以下假设PATH_TO_CL_FOLDER是你的CL文件夹)

After doing this, you should add the folder that contains CL folder into the include path in your makefile. (The following assumes that PATH_TO_CL_FOLDER is your CL folder)

对于那些使用 Android.mk 的人

如果您使用 Application.mk 和 Android.mk,并使用传统的 ndk-build 方式构建您的本机库,您应该将 CL 目录的路径添加到 LOCAL_C_INCLUDES 变量中 在 Android.mk 中).

If you work with Application.mk and Android.mk, and build your native library using traditional ndk-build way, you should add the path to CL directory into the LOCAL_C_INCLUDES variable in Android.mk).

LOCAL_C_INCLUDES += PATH_TO_CL_FOLDER

对于那些在 Android Studio 中使用 Gradle 的人(这就是你所需要的)

编辑 build.gradle,在 cFlags 字段中添加包含路径,如下所示:

Edit build.gradle, add your include path in the cFlags field as shown below:

android {
  defaultConfig {
    ndk {
                moduleName "yourlib"
                stl "stlport_static"
                ldLibs "log", "z"
                cFlags "-IPATH_TO_CL_FOLDER"
        }
    ...
  }
  ...
}

这篇关于Android Studio 致命错误:CL/cl.h No such file or directory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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