在Android项目

时间:2017-02-21 15:39:56

标签: android opencl

我想重用一个Android Eclipse项目来使用OpenCL库。 我曾经为我之前的手机设置了一个三星Alpha的eclipse项目。 现在我得到了一个moto Z,我想修改thgis项目以重用它。

我从手机上获取了libOpenCL.so文件,我在项目中更改了文件,但编译发送给我错误:

    [x86_64] SharedLibrary  : libJNIProcessor.so
/home/xxxx/NVPACK/android-sdk-linux/ndk-bundle/toolchains/x86_64-4.9/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: jni/libs/libOpenCL.so: incompatible target
jni/include/CL/cl.hpp:1090: error: undefined reference to 'clReleaseContext'
jni/include/CL/cl.hpp:1099: error: undefined reference to 'clReleaseCommandQueue'
jni/include/CL/cl.hpp:1135: error: undefined reference to 'clReleaseKernel'
jni/processor.cpp:143: error: undefined reference to 'clRetainProgram'
jni/processor.cpp:145: error: undefined reference to 'clGetProgramInfo'
jni/processor.cpp:147: error: undefined reference to 'clGetProgramBuildInfo'
jni/processor.cpp:152: error: undefined reference to 'clGetProgramBuildInfo'
jni/processor.cpp:156: error: undefined reference to 'clGetProgramBuildInfo'
jni/processor.cpp:159: error: undefined reference to 'clReleaseProgram'
jni/include/CL/cl.hpp:2878: error: undefined reference to 'clEnqueueWriteBuffer'
jni/include/CL/cl.hpp:1106: error: undefined reference to 'clRetainMemObject'
jni/include/CL/cl.hpp:2548: error: undefined reference to 'clSetKernelArg'
jni/include/CL/cl.hpp:1108: error: undefined reference to 'clReleaseMemObject'
jni/include/CL/cl.hpp:1106: error: undefined reference to 'clRetainMemObject'
jni/include/CL/cl.hpp:2548: error: undefined reference to 'clSetKernelArg'
jni/include/CL/cl.hpp:1108: error: undefined reference to 'clReleaseMemObject'
jni/include/CL/cl.hpp:2548: error: undefined reference to 'clSetKernelArg'
jni/include/CL/cl.hpp:2548: error: undefined reference to 'clSetKernelArg'
jni/include/CL/cl.hpp:1106: error: undefined reference to 'clRetainMemObject'
jni/include/CL/cl.hpp:1108: error: undefined reference to 'clReleaseMemObject'
jni/include/CL/cl.hpp:1106: error: undefined reference to 'clRetainMemObject'
jni/include/CL/cl.hpp:1108: error: undefined reference to 'clReleaseMemObject'
jni/include/CL/cl.hpp:3248: error: undefined reference to 'clEnqueueNDRangeKernel'
jni/include/CL/cl.hpp:1144: error: undefined reference to 'clReleaseEvent'
jni/include/CL/cl.hpp:1090: error: undefined reference to 'clReleaseContext'
jni/include/CL/cl.hpp:1088: error: undefined reference to 'clRetainContext'
jni/include/CL/cl.hpp:1090: error: undefined reference to 'clReleaseContext'
jni/include/CL/cl.hpp:1045: error: undefined reference to 'clGetContextInfo'
jni/include/CL/cl.hpp:1099: error: undefined reference to 'clReleaseCommandQueue'
jni/include/CL/cl.hpp:1097: error: undefined reference to 'clRetainCommandQueue'
jni/include/CL/cl.hpp:1099: error: undefined reference to 'clReleaseCommandQueue'
jni/include/CL/cl.hpp:2668: error: undefined reference to 'clBuildProgram'
jni/include/CL/cl.hpp:2769: error: undefined reference to 'clCreateKernel'
jni/include/CL/cl.hpp:1135: error: undefined reference to 'clReleaseKernel'
jni/include/CL/cl.hpp:1133: error: undefined reference to 'clRetainKernel'
jni/include/CL/cl.hpp:1135: error: undefined reference to 'clReleaseKernel'
jni/include/CL/cl.hpp:2769: error: undefined reference to 'clCreateKernel'
jni/include/CL/cl.hpp:1135: error: undefined reference to 'clReleaseKernel'
jni/include/CL/cl.hpp:1133: error: undefined reference to 'clRetainKernel'
jni/include/CL/cl.hpp:2769: error: undefined reference to 'clCreateKernel'
jni/include/CL/cl.hpp:1133: error: undefined reference to 'clRetainKernel'
jni/include/CL/cl.hpp:1090: error: undefined reference to 'clReleaseContext'
jni/include/CL/cl.hpp:1099: error: undefined reference to 'clReleaseCommandQueue'
/home/xxx/NVPACK/android-sdk-linux/ndk-bundle/build/core/build-binary.mk:702 : la recette pour la cible « obj/local/x86_64/libJNIProcessor.so » a échouée
jni/include/CL/cl.hpp:1473: error: undefined reference to 'clGetPlatformIDs'
jni/include/CL/cl.hpp:1480: error: undefined reference to 'clGetPlatformIDs'
jni/include/CL/cl.hpp:1534: error: undefined reference to 'clCreateContextFromType'
jni/include/CL/cl.hpp:2791: error: undefined reference to 'clCreateCommandQueue'
jni/include/CL/cl.hpp:2602: error: undefined reference to 'clCreateProgramWithSource'
jni/include/CL/cl.hpp:1126: error: undefined reference to 'clReleaseProgram'
jni/include/CL/cl.hpp:1037: error: undefined reference to 'clGetProgramBuildInfo'
jni/include/CL/cl.hpp:1855: error: undefined reference to 'clCreateBuffer'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

编辑: 我删除了所有OpenCL程序,我只是设置了OpenCL lib,我得到了:

x86_64-linux-android/bin/ld: error: jni/libs/libOpenCL.so: incompatible target
/home/xxxx/NVPACK/android-sdk-linux/ndk-bundle/build/core/build-binary.mk:702 : la recette pour la cible « obj/local/x86_64/libJNIProcessor.so » a échouée

编辑2:

我终于下载了NDK10e(我第一次编译这个项目时使用的那个)并且构建工作正常。但是在执行时我在日志中得到了错误:

02-22 10:00:41.077  7302  7302 D AndroidRuntime: Shutting down VM
02-22 10:00:41.078  7302  7302 E AndroidRuntime: FATAL EXCEPTION: main
02-22 10:00:41.078  7302  7302 E AndroidRuntime: Process: com.example.subsamplecamera, PID: 7302
02-22 10:00:41.078  7302  7302 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libGLES_mali.so" not found
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at java.lang.Runtime.loadLibrary0(Runtime.java:977)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at java.lang.System.loadLibrary(System.java:1530)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at com.example.subsamplecamera.MainActivity.<clinit>(MainActivity.java:30)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at java.lang.Class.newInstance(Native Method)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at android.app.Instrumentation.newActivity(Instrumentation.java:1100)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2551)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at android.app.ActivityThread.-wrap12(ActivityThread.java)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:102)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:154)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6123)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
02-22 10:00:41.078  7302  7302 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.ru

但我没有mali GPU,为什么该项目正在调用mali库

编辑3: 我终于做到了,程序编译正确,应用程序运行。 我将标准NDK10e更改为Snapdragon LLVM,它似乎有效。 现在我在执行OpenCL内核时添加了一个错误。:

gQueue.enqueueNDRangeKernel(gNV21Kernel,
                cl::NullRange,
                cl::NDRange( (int)ceil((float)w/16.0f)*16,(int)ceil((float)h/16.0f)*16),
                cl::NDRange(4,1),
                NULL,
                NULL);

我不明白这个错误。有人可以帮助我吗?     CL :: error -36

1 个答案:

答案 0 :(得分:1)

基本上,问题可能是因为:

  • Android上的OpenCL并未得到Google的正式支持。所以,你 可能会在某些Android设备上看到OpenCL不受支持。 虽然到目前为止,大多数旗舰设备都支持OpenCL, 例如采用高通/三星芯片组的设备(谷歌Nexus除外) 设备,但有一些Nexus设备的解决方法,请 谷歌在线)。
  • 如果您清楚地知道您的应用只能在某些设备上运行,那么 支持OpenCL,你可以继续这样做。高通公司的OpenCL和 三星芯片组目前非常稳定,编译器也有 已经优化了几年;因此,你可以期待一些 这些设备的良好性能。