Failed building android_rpc with LLVM and OpenCL

app/src/main/jni/config.mk below:

APP_ABI = all
APP_PLATFORM = android-24
USE_OPENCL = 1
USE_VULKAN = 0
ifeq ($(USE_VULKAN), 1)
  APP_PLATFORM = android-24
endif
ADD_C_INCLUDES += /usr/include/
ADD_C_INCLUDES += /usr/include/x86_64-linux-gnu
ADD_LDLIBS = /usr/lib/x86_64-linux-gnu/libOpenCL.so

When run ‘gradle clean build’, got error:

In file included from /share_sdb/software/android/ndk-bundle/sources/cxx-stl/llvm-libc++/include/unordered_map:402:
In file included from /share_sdb/software/android/ndk-bundle/sources/cxx-stl/llvm-libc++/include/__hash_table:19:
/share_sdb/software/android/ndk-bundle/sources/cxx-stl/llvm-libc++/include/cmath:315:9: error: no member named 'signbit' in the global namespace; did you mean '__signbit'?
using ::signbit;
      ~~^
/usr/include/bits/mathcalls.h:361:20: note: '__signbit' declared here
__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))

... ...

In file included from /share_sdb/software/android/ndk-bundle/sources/cxx-stl/llvm-libc++/include/unordered_map:402:
In file included from /share_sdb/software/android/ndk-bundle/sources/cxx-stl/llvm-libc++/include/__hash_table:19:
/share_sdb/software/android/ndk-bundle/sources/cxx-stl/llvm-libc++/include/cmath:316:9: error: no member named 'fpclassify' in the global namespace; did you mean '__fpclassify'?
using ::fpclassify;
      ~~^
/usr/include/bits/mathcalls.h:357:20: note: '__fpclassify' declared here
__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value))
                   ^

What is the NDK version and How did you install (Through Android Studio ?)?

NDK version: 19.2.5345600
I download android-ndk-r19c-linux-x86_64.zip from https://developer.android.com/ndk/downloads, then unzip and set PATH.

You are using a cross-compiler with your local include files for x86.

So how can I build it on local linux pc? I set ADD_C_INCLUDES with a path of CL header files which download from web, but still error:

13:47:44.998 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] > Task :app:buildJni
13:48:11.261 [QUIET] [system.out] [arm64-v8a] SharedLibrary : libtvm4j_runtime_packed.so
13:48:11.603 [ERROR] [system.err] /share_sdb/software/tvm/apps/android_rpc/app/src/main/obj/local/arm64-v8a/objs/tvm4j_runtime_packed/ml_dmlc_tvm_native_c_api.o: In fun
ction tvm::runtime::cl::OpenCLWorkspace::AllocDataSpace(DLContext, unsigned long, unsigned long, DLDataType)': 13:48:11.603 [ERROR] [system.err] /share_sdb/software/tvm/apps/android_rpc/app/src/main/jni/../../../../../../include/../src/runtime/opencl/opencl_device_api.cc:125: un defined reference toclCreateBuffer

Could you please show me a right demo or config?

The details may depend on a particular GPU that you want to target. For example, here’s an SDK (and some documents) for Adreno: https://developer.qualcomm.com/software/adreno-gpu-sdk/tools, but you may need something else, depending on your device.

1 Like

Thank you! I got wrong include files. It works now.