siposcsaba89 / stereo-sgm-opencl

SGM implementation
56 stars 15 forks source link

undefined reference to `clCreateCommandQueueWithProperties' #1

Closed yangruixuan closed 7 years ago

yangruixuan commented 7 years ago

Hi siposcsaba89. First, thank you for share this project. I'm new in OpenCL andwhen I try to build this project I got these errors. I tried several devices and got the some errors. Please give some help, Thanks.

[ 50%] Built target sgm-cl [ 75%] Linking CXX executable sgm-cl-test sgm-cl/libsgm-cl.a(sgm-cl.cpp.o): In function cl::CommandQueue::CommandQueue(cl::Context const&, cl::Device const&, unsigned long long, int*)': sgm-cl.cpp:(.text._ZN2cl12CommandQueueC2ERKNS_7ContextERKNS_6DeviceEyPi[_ZN2cl12CommandQueueC5ERKNS_7ContextERKNS_6DeviceEyPi]+0x6c): undefined reference toclCreateCommandQueueWithProperties' collect2: error: ld returned 1 exit status CMakeFiles/sgm-cl-test.dir/build.make:112: recipe for target 'sgm-cl-test' failed make[2]: [sgm-cl-test] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/sgm-cl-test.dir/all' failed make[1]: [CMakeFiles/sgm-cl-test.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2

siposcsaba89 commented 7 years ago

Hi yangruixuan,

Thanks for using :)

I haven't experienced the problem you described, but I think I know where to start digging. I think it's because I use the "cl.hpp" wrapper around the opencl c version, and the cl.hpp you have got uses the "clCreateCommandQueueWithProperties" function which is not built into the opencl.so on your system, or if you have multiple one, the one you linking with. I recommend you to download a different cl.hpp version from the web, for example this one from KHronos site https://www.khronos.org/registry/OpenCL/api/2.1/cl.hpp and use that header instead of the current one.

And another thing, this is a very preliminary version, so if you want to change the opencl platfom or the device the code running on, you should change the sgm-cl/sgm-cl.cpp file 8, 9 row to the platform-index and device index you want (the default indices here are (1 - "platform", 0 - "device")), if you have only one platform this may cause a failure, try to change it to (0,0).

I hope it helps, please let me know if you have any other questions.

Best Regards, Csaba

yangruixuan commented 7 years ago

Hi siposcsaba89, Thank your for your help! It's works! I got these errors is because I used the wrong cl.hpp file. So it didn't match the so file.