0

I want to develop a Qt C++ application using OpenCL.

The problem is I don't know what do I need to install/download to use OpenCL in my project. I am confused by many obsolete threads over the internet. I have downloaded the SDK repo from official Khronos page: https://github.com/KhronosGroup/OpenCL-SDK

But there are no .lib nor .so files inside, only header files, so I cannot link the library to my project.

I am using Windows 10 and I have an AMD graphic card, but my goal is to develop an application which can be run on any dedicated/integrated GPU.

What is the approach to just make it work and start coding?

Arus23
  • 89
  • 6
  • ***But there are no .lib nor .so files inside,*** You need to use CMake to generate a project file or makefile and build that using the same compiler you will use for your application. The [https://github.com/KhronosGroup/OpenCL-SDK#readme](https://github.com/KhronosGroup/OpenCL-SDK#readme) gives you the instructions on get the dependencies and how to build. – drescherjm Aug 29 '21 at 14:11
  • @drescherjm I generated the project as described in the readme.md but I still have no idea how to link it to my c++ project. Building samples got me generated 2 files: ./build/CMakeFiles/3.16.3/CompilerIdC/a.out ./build/CMakeFiles/3.16.3/CompilerIdCXX/a.out But I still cannot use includes from OpenCL after linking one of them (tried both) as a library. – Arus23 Aug 29 '21 at 14:31
  • After you generated the Makefile in the build folder you created did you type make to build the code? You could also type `cmake --build .` in the build folder. – drescherjm Aug 29 '21 at 14:34
  • The files you tried were just test executables produced to determine information about your compiler. – drescherjm Aug 29 '21 at 14:51
  • CMake doesn't work on Windows, so I compiled on WSL using gcc, but still my project doesn't see the includes from OpenCL. – Arus23 Aug 29 '21 at 15:51
  • I have used CMake at work for all my projects since 2008. It certainly works in windows. Edit: Maybe you mean it does not work for this library for some reason?? – drescherjm Aug 29 '21 at 16:40
  • I mean i get an error CMAKE_C_COMPILER not set, after EnableLanguage after running `cmake .` Still didn't find a way to fix this. – Arus23 Aug 29 '21 at 16:56
  • You are probably not running from a cmd.exe window or shell with your compiler in the PATH. You also may need to use the -G command line option to specify what generator to use. – drescherjm Aug 29 '21 at 17:23
  • Path is set correctly and I can use g++ and gcc straight from cmd. Maybe I should compile that lib manually? But I'm not sure whether to make that static or dynamic library. – Arus23 Aug 29 '21 at 17:38
  • ***Maybe I should compile that lib manually?*** I would expect that to be much more difficult than getting your CMake to work. – drescherjm Aug 29 '21 at 17:41
  • Even though I managed to build OpenCL-Headers on WSL it still doesn't make sense, because after executing commands cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/chosen/install/prefix and cmake --build build --target install mentioned in [OpenCL-Headers](https://github.com/KhronosGroup/OpenCL-Headers) the .lib file is not produced. No errors were thrown. – Arus23 Aug 29 '21 at 18:19
  • I tried to build myself in msys2 but failed in a few different ways with compiler errors depending on how I configured or what CMake exe I used. I am not a msys2 / mingw expert. I use msvc at the day job. I did notice that the headers and loader are packages in msys2 but not sure if that is all you need. – drescherjm Aug 29 '21 at 19:24

1 Answers1

0

Once you have installed the graphics driver, you don't need to install anything else. To develop OpenCL code, you just need the OpenCL header files and the .lib file. You can get them either from here (they work for AMD as well, but only OpenCL 1.2) or from Khronos directly (you will have to compile the .lib yourself).

ProjectPhysX
  • 4,535
  • 2
  • 14
  • 34