KhronosGroup / OpenCL-SDK

OpenCL SDK
Apache License 2.0
572 stars 120 forks source link

clGetPlatformIDs return -1001 for android emulator and real phone #89

Open DavdGao opened 1 year ago

DavdGao commented 1 year ago

I cross-compiled OpenCL-SDK as follows. However, when I run clGetPlatformIDs function, it returns -1001. What can I do to fix it?

#!/bin/bash 

set -e

git clone --recurse-submodules https://github.com/KhronosGroup/OpenCL-SDK.git
mkdir OpenCL-SDK/build
cd OpenCL-SDK/build

# cross-compile for  android
NDK_PATH=/Users/david/Library/Android/sdk/ndk/25.1.8937393/
TOOLCHAIN=${NDK_PATH}/toolchains/llvm/prebuilt/darwin-x86_64

cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_DOCS=OFF \
    -DBUILD_EXAMPLES=OFF \
    -DBUILD_TESTING=OFF \
    -DBUILD_TESTS=OFF \
    -DOPENCL_SDK_BUILD_SAMPLES=OFF \
    -DOPENCL_SDK_TEST_SAMPLES=OFF \
    -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
    -DCMAKE_C_COMPILER=${TOOLCHAIN}/bin/aarch64-linux-android33-clang \
    -DCMAKE_CXX_COMPILER=${TOOLCHAIN}/bin/aarch64-linux-android-33-clang++ \
    -DBUILD_SHARED_LIBS=OFF \
    -DBUILD_STATIC_LIBS=ON \
    -DANDROID_ABI=arm64-v8a \
    -DANDROID_PLATFORM=android-33

cmake --build . --config Release
cmake --install . --prefix install_android
DavdGao commented 1 year ago

maybe related to #84