How to link OpenCl library to Clion IDE - c++

I am writing a HellowWorld example using opencl library in Clion.
My problem is problem is that i get the error message
[ 50%] Linking CXX executable HelloWorldOpencl
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/HelloWorldOpencl.dir/main.cpp.o: in function `main':
/home/belkacem/CLionProjects/HelloWorldOpencl/main.cpp:11: undefined reference to `clGetPlatformIDs'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/HelloWorldOpencl.dir/build.make:84: HelloWorldOpencl] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/HelloWorldOpencl.dir/all] Error 2
gmake: *** [Makefile:84: all] Error 2
my opencl is installed correctly in the following directiries
libOpenCL1 - OpenCL ICD Bindings
/etc/alternatives/libOpenCL.so.1
/usr/lib64/libOpenCL.so.1
/usr/lib64/ocl-icd
/usr/lib64/ocl-icd/libOpenCL.so.1
/usr/lib64/ocl-icd/libOpenCL.so.1.0.0
/usr/share/doc/packages/libOpenCL1
/usr/share/doc/packages/libOpenCL1/README
7 files total
How i can link the library with Clion IDE?

Your OpenCL installation might be incomplete - you should have a library libOpenCL.so somewhere, and also at least one ICD file in the /etc/OpenCL/vendors directory.

Related

Building AWS secure tunneling localproxy on rPi

I'm trying to compile the AWS iot localproxy on an rPi (have tried 3 and 4 and getting the same issue). I follow the instructions here >> https://github.com/aws-samples/aws-iot-securetunneling-localproxy
I have been sucessful compiling on macOS and the binary works, but when building on an rPi I get the folowing error...
[ 4%] Linking CXX executable bin/localproxytest
/usr/bin/ld: /usr/local/lib/arm-linux-gnueabihf/libprotobuf-lite.a(arena.cc.o): in function `google::protobuf::internal::ThreadSafeArena::Init(bool)':
arena.cc:(.text+0xa60): undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/localproxytest.dir/build.make:292: bin/localproxytest] Error 1
make[1]: *** [CMakeFiles/Makefile2:97: CMakeFiles/localproxytest.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
It seems to be a problem linking to '__atomic_fetch_add_8' or the atomic libs? Any clues on how to resolve? Anyone been successful building this on an rPi?
I believe there is an issue with CMake and the order of linking with ld.
In CMakeLists.txt
Moving atomic to be the last link command after all the sources fixed this for me
https://github.com/aws-samples/aws-iot-securetunneling-localproxy/blob/main/CMakeLists.txt#L94
if(NOT APPLE AND NOT MSVC) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} atomic) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} atomic) endif()
should be below
https://github.com/aws-samples/aws-iot-securetunneling-localproxy/blob/main/CMakeLists.txt#L111
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${Protobuf_LITE_STATIC_LIBRARY})

linking error cxx: cannot find -lvulkan

When I tried to compile example from Anvil framework for Vulkan I get following errors:
[ 97%] Linking CXX executable OutOfOrderRasterization
/usr/bin/ld: cannot find -lvulkan
collect2: error: ld returned 1 exit status
CMakeFiles/OutOfOrderRasterization.dir/build.make:126: recipe for target 'OutOfOrderRasterization' failed
make[2]: *** [OutOfOrderRasterization] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/OutOfOrderRasterization.dir/all' failed
make[1]: *** [CMakeFiles/OutOfOrderRasterization.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
How i need to configure Vulkan to resolve it? (Ubuntu)
Check you LIBRARY paths. You might need to download and install vulkan. There should a .so file in one your library paths(/usr/lib{,64},/lib{,64}, /usr/share/lib{,64}) named to the effect of libvulkan.numbers.so.
See this ask ubuntu question: https://askubuntu.com/questions/796442/ld-cannot-find-lvulkan
CMake versions 3.7 and later ship with a FindVulkan.cmake module that finds the Vulkan includes and library for you if you have a Vulkan SDK installed and the VULKAN_SDK environment variable set. The CMake module also finds the includes and library if you have installed a Vulkan package to your system directories. The Getting Started guide on the LunarXchange website has some additional detail.

Where does the CLion IDE look for header files?

I'm using the CLion IDE and need to put some OpenGL files in. In the JetBrains/CLion folder there's a bin and lib folder. In the lib folder theres jar files, do I put the header and dlls in here?
get this error:
CMakeFiles\GL.dir/objects.a(main.cpp.obj): In function `glutInit_ATEXIT_HACK':
c:/mingw/include/gl/glut.h:486: undefined reference to `__glutInitWithExit'
CMakeFiles\GL.dir/objects.a(main.cpp.obj): In function `glutCreateWindow_ATEXIT_HACK':
c:/mingw/include/gl/glut.h:503: undefined reference to `__glutCreateWindowWithExit'
CMakeFiles\GL.dir/objects.a(main.cpp.obj): In function `glutCreateMenu_ATEXIT_HACK':
c:/mingw/include/gl/glut.h:549: undefined reference to `__glutCreateMenuWithExit'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\GL.dir\build.make:86: recipe for target 'GL.exe' failed
mingw32-make.exe[3]: *** [GL.exe] Error 1
CMakeFiles\Makefile2:59: recipe for target 'CMakeFiles/GL.dir/all' failed
CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/GL.dir/rule' failed
mingw32-make.exe[2]: *** [CMakeFiles/GL.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/GL.dir/rule] Error 2
Makefile:109: recipe for target 'GL' failed
mingw32-make.exe: *** [GL] Error 2
From the FAQ here:
At present CLion supports GCC and Clang compilers and is guided by these two to get the libraries and headers paths.
So it depends on the compiler CLion is using where it looks for the header files.

Compiling opencv for ARM platform

I want to put C++ opencv algorithm on ARM-Linux based camera.
I am able to do Configure and Generate steps for opencv build using CMake.
Then when I try to do “make” operation on terminal I am facing some issue.
->>>>>>>>>>>>>>>>>Issue->>>
Linking CXX shared library ../../lib/libopencv_core.so
/opt/montavista_pro_arm_v5t_le/bin/../lib/gcc/armv5tl-montavista-linux-gnueabi/4.2.0/../../../../armv5tl-montavista-linux-gnueabi/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make[2]: *** [lib/libopencv_core.so.3.0.0] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [all] Error 2
->>>>>>>>>>>>>>>>
I searched online. I tried to do some stuff from link http://answers.opencv.org/question/33564/opencv-master-branch-compilation-issue/ . I removed ${ZLIB_LIBRARIES} option in modules/core/CMakeLists.txt.
But still I am facing same issue.
Can you please help me with that.

Compiling ROS on RPI fails at opencv with undefined reference to 'header'

I'm trying to compile ROS (Robot Operating System) on a Raspberry Pi (Raspbian) following these instructions and got to the point to compile ROS, which fails at compiling opencv with undefined reference to 'header':
[ 97%] Built target opencv_videostab
[ 98%] Built target opencv_haartraining_engine
Linking CXX executable ../../bin/opencv_createsamples
../../lib/libopencv_highgui.so.2.4.6: undefined reference to `header'
collect2: ld returned 1 exit status
make[2]: *** [bin/opencv_createsamples] Error 1
make[1]: *** [apps/haartraining/CMakeFiles/opencv_createsamples.dir/all] Error 2
make: *** [all] Error 2
<== Failed to process package 'opencv2':
Command '/home/ilagi/ros_catkin_ws/install_isolated/env.sh make -j1 -l1' returned non-zero exit status 2
I googled to try to figure out what header file might be missing, but unfortunately didn't get anywhere.
I hope somebody will have an idea about at least the directions to go from here.
Thanks
I guess I'm going to answer my own question. I don't exactly know which dependency caused this particular error, but I had recompiled ffmpeg based on the instructions provided at http://ariandy1.wordpress.com/2013/02/13/raspberry-pi-rasbian-opencv/ and now I managed to get ROS to compile opencv.