Android的工作室致命错误:CL / cl.h没有这样的文件或目录 [英] Android Studio fatal error: CL/cl.h No such file or directory

查看:1354
本文介绍了Android的工作室致命错误:CL / cl.h没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立的Andr​​oid 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.

任何想法如何解决这一问题?我看到引用<一个href=\"http://stackoverflow.com/questions/21301905/compile-opencl-program-using-cl-cl-h-file\">here似乎从命令行运行GCC。我想这个从Android工作室只是工作。

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.
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 code(不带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的构建的方式建立自己的机库,您应该将该路径添加到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中的工作(这是你所需要的)

For those who work with Gradle in Android Studio (This is what you need)

编辑的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的工作室致命错误:CL / cl.h没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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