Android Studio fatal error: CL / cl.h No such file or directory
I am trying to create an openCL program in Android Studio and keep working on the following problem:
Android Studio fatal error: CL/cl.h No such file or directory
I was looking for all this solution for "visual studio".
I thought it might be helpful if we had a solution specified specifically for Android Studio and this error.
Any ideas how to fix this? I can see the links here show up on the gcc command line. I want this to only work with Android Studio.
source to share
OpenCL is not part of Android, so you cannot find cl.h. Download the required CL header files from here: https://www.khronos.org/registry/cl/
Download cl.h with the correct version (same as the CL version you are using, for example CL 1.1).
Include header files in your OpenCL program, then you're good to go.
Edited 18.4.2012:
To enable OpenCL header files, you can do the following:
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/opencl.h>
#endif
But if you are programming only CL code (no CL-GL interoperability), you just need to include CL / cl.h:
#include <CL/cl.h>
After that, you must add the folder containing the CL folder to the include path in your file. (The following assumes PATH_TO_CL_FOLDER is your CL folder)
For those using Android.mk
If you are working with Application.mk and Android.mk and are building your own library using the traditional method ndk-build
, you should add the CL's directory path LOCAL_C_INCLUDES variable
in Android.mk).
LOCAL_C_INCLUDES += PATH_TO_CL_FOLDER
For those working with Gradle in Android Studio (this is what you need)
Modify build.gradle, add your include path to cFlags field as below:
android {
defaultConfig {
ndk {
moduleName "yourlib"
stl "stlport_static"
ldLibs "log", "z"
cFlags "-IPATH_TO_CL_FOLDER"
}
...
}
...
}
source to share