2017-02-21 40 views
0

我想重複使用Android Eclipse項目來使用OpenCL庫。 我曾經爲我之前的手機設置了我的eclipse項目三星阿爾法。 現在我得到一個moto Z,我想修改這個項目來重用它。在Android項目中集成LibOpenCL

我從我的手機得到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 

但我沒有馬裏GPU,爲什麼項目呼籲馬裏庫

編輯3: 我終於成功了,程序編譯正確和應用程序運行。 我將標準NDK10e更改爲Snapdragon LLVM,它看起來可行。 現在我OpenCL的內核executiong:

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 ::錯誤-36

回答

1

基本上,這個問題可能造成的原因:

  • OpenCL的Android上沒有正式由谷歌支持。因此,您可能會發現 可能會在某些Android設備上看到OpenCL不受支持。儘管到目前爲止,大多數旗艦設備都具有OpenCL支持,例如帶有高通/三星芯片組的設備(谷歌Nexus 設備除外,但對於某些Nexus設備有解決方法,請在線谷歌聯繫我們 ) 。
  • 如果您清楚地知道您的應用只能在某些設備上運行,其中 支持OpenCL,則可以繼續操作。 Qualcomm上的OpenCL和 三星芯片組現在非常穩定,編譯器 已經優化了好幾年;因此,您可以期望這些設備具有良好的性能。
+0

謝謝你的回答。 OpenCL lib似乎得到了支持,因爲在Qualcomm網站上有用於我的芯片組的OpenCL文件的adrenosdk,但是沒有完整的項目。 –

+0

沒關係! :)讓我檢查一下對你來說 –

+0

你能分享鏈接寫在哪裏OpenCL lib被支持嗎? –