KhronosGroup / OpenCL-Headers

Khronos OpenCL-Headers
Apache License 2.0
674 stars 235 forks source link

Why cannot find <CL\opencl.h> when using Android NDK Building? #186

Open FdyCN opened 2 years ago

FdyCN commented 2 years ago

Hi guys, i got a problem. when I include opencl.hpp in my project. BUT, when i build executable for android 64 os using NDK. Here comes a compiling error, happened at this line: image

my ndk version is : r22b `/Users/admin/Desktop/Demo/third_party/CL/opencl.hpp:530:10: fatal error: 'CL/opencl.h' file not found

include <CL/opencl.h>

` i wonder why it's wrong? is there no matched head in target platform? and how can i fix it?

Please help me and thanks a lot!

jansol commented 9 months ago

AFAIK Android officially does not support OpenCL so that header probably is not part of the NDK.

ahorek commented 1 week ago

OpenCL support is not part of the NDK, but it's doable:

1/ clone this repository and include include CL/opencl.h to your project like this CXXFLAGS += -I./OpenCL-Headers/include 2/ copy libOpenCL.so from your phone (usual location are /system/vendor/lib64 or /system/vendor/lib) and link it LDFLAGS += -lOpenCL -L./OpenCL_redist/lib

now it should compile fine and you can test it via Termux

export LD_LIBRARY_PATH="/system/vendor/lib64"
./run_your_binary