Simple OpenCL under QT Creator
-
Dears,
I am using QTCreator w CMake to get compiled and run OpenCL example where I am getting errors to build.
Simple example minimal-opencl-on-windows can be built with MinGW/Windows
>gcc --version gcc (x86_64-posix-seh-rev2, Built by MinGW-W64 project) 7.1.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
such as
>gcc -Ic:\opencl\include\ main.c -Lc:\opencl\bin\x86_64\ -lOpenCL -o main.exe
or
gcc -Ic:\opencl\include\ main.c c:\opencl\bin\x86_64\OpenCL.dll -o main.exe
under QTCreator/CMake I have CMakeLists.txt
cmake_minimum_required(VERSION 2.8) project(opencl_test) add_executable(${PROJECT_NAME} "main.c") set (CMAKE_CXX_FLAGS "-lOpenCL") INCLUDE_DIRECTORIES("c:\\opencl\\include\\") LINK_DIRECTORIES("c:\\opencl\\bin\\x86_64\\") target_link_libraries(opencl_test OpenCL.dll)
unfortunatelly I am getting error
:-1: error: cannot find -lOpenCL collect2.exe:-1: error: error: ld returned 1 exit status
I am looking for resolution of this to get it compiled, can you help please?
Thank you.
-
Hi,
Where's OpenCL.lib on your system ?
-
@peter_cz said in Simple OpenCL under QT Creator:
:-1: error: cannot find -lOpenCL
collect2.exe:-1: error: error: ld returned 1 exit statusCan you please also show the compile output before? Especially the effective linker call.
As shot in the dark, I'd try to remove the trailing backslash from LINK_DIRECTORIES:
LINK_DIRECTORIES("c:\\opencl\\bin\\x86_64")
because I already had problems with qmake in such a case.
-
@peter_cz Adding libraries is actually done like this:
LIBS += -Lc:/opencl/bin/x86_64 -lOpenCL
See http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html
Also, no need to use \\, just use / (even on Windows). -
@jsulm said in Simple OpenCL under QT Creator:
LIBS += -Lc:/opencl/bin/x86_64 -lOpenCL
See http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html
Also, no need to use \, just use / (even on Windows).Did you read that he uses CMake, not qmake?