Thanks to @Matthias, I managed to put the final piece of the puzzle. So, in conclusion:
- The 32-bit (x86) version of MinGW can't link your application against the 64-bit (x64) version of the OpenCL library. Attempting this will give rise to undefined reference errors.
- I had to comment away the line
#define __NO_STD_VECTOR
or I would get a compilation error. - When adding a library using the built-in "Add Library" function in Qt Creator, it will put
$$PWD
before the paths and put no space in between. This is supposed to be a separate folder, so there has to be a space between$$PWD
and the path you specified. For theLIBS
specification, there also has to be an extra-L
after the space. - Make sure there is no
d
added in the ent of the library name if you have no such library file. There is an option "Add "d" suffix for debug version" when adding an internal or external library that I had missed to uncheck.
The code that finally compiled:
main.cpp:
#include <utility>
//#define __NO_STD_VECTOR // Use cl::vector instead of STL version
#include <CL/cl.hpp>
int main()
{
return 0;
}
Qt project file:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/ -LC:/Program1/Intel/OpenCL_SDK/3.0/lib/x86/ -lOpenCL
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/ -LC:/Program1/Intel/OpenCL_SDK/3.0/lib/x86/ -lOpenCL
else:unix: LIBS += -L$$PWD/ -LC:/Program1/Intel/OpenCL_SDK/3.0/lib/x86/ -lOpenCL
INCLUDEPATH += $$PWD/ C:/Program1/Intel/OpenCL_SDK/3.0/include
DEPENDPATH += $$PWD/ C:/Program1/Intel/OpenCL_SDK/3.0/include