I'm trying to compile the following C++ code with Qt Creator, on Windows 7 64-bit and with the Intel SDK for OpenCL Applications 2013:
#include <utility>
#define __NO_STD_VECTOR // Use cl::vector instead of STL version
#include <CL/cl.hpp>
int main()
{
return 0;
}
and here is my .pro file:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/C:/Program1/Intel/OpenCL_SDK/3.0/lib/x64/ -lOpenCL
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/C:/Program1/Intel/OpenCL_SDK/3.0/lib/x64/ -lOpenCLd
else:unix: LIBS += -L$$PWD/C:/Program1/Intel/OpenCL_SDK/3.0/lib/x64/ -lOpenCL
INCLUDEPATH += C:/Program1/Intel/OpenCL_SDK/3.0/include
DEPENDPATH += $$PWD/C:/Program1/Intel/OpenCL_SDK/3.0/include
I had to remove $$PWD/
(which Qt Creator added to the beginning of each path for some unknown reason) in INCLUDEPATH
, otherwise the compiler wouldn't find CL/cl.cpp
.
Anyway, when trying to compile, I get the following error message:
In file included from ..\opencl_test\main.cpp:3:0:
C:\Program1\Intel\OpenCL_SDK\3.0\include/CL/cl.hpp:680:1: error: expected unqualified-id before '{' token
{
^
followed by a lot of other error messages. Why do I get these errors and how do I resolve them?
Update 1
As prajmus pointed out in a comment, $$PWD
is the directory of the .pro file, and hence a space is missing after it, which Qt Creator missed to put there. In the LIBS
specification, -L
also has to be added before C:
.
I fixed that, but I still get the same error message.
Update 2
If I comment out the line #define __NO_STD_VECTOR
, the error messages disappear, but instead I get
c:/program1/qt/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lOpenCLd
Changing -lOpenCLd
to -lOpenCL
gets rid of that warning, but instead gives me
00:38:14: Running steps for project opencl_test...
00:38:14: Configuration unchanged, skipping qmake step.
00:38:14: Starting: "C:\Program1\Qt\Tools\mingw48_32\bin\mingw32-make.exe"
C:\Program1\Qt\5.2.0\mingw48_32\bin\qmake.exe -spec win32-g++ CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile ..\opencl_test\opencl_test.pro
C:/Program1/Qt/Tools/mingw48_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'E:/Work/Programs/Test_programs/opencl_test/build-opencl_test-Desktop_Qt_5_2_0_MinGW_32bit-Debug'
g++ -Wl,-subsystem,console -mthreads -o debug\opencl_test.exe debug/main.o -LE:/Work/Programs/Test_programs/opencl_test/opencl_test/ -LC:/Program1/Intel/OpenCL_SDK/3.0/lib/x64/ -lOpenCL
debug/main.o: In function `getPlatformVersion':
C:/Program1/Intel/OpenCL_SDK/3.0/include/CL/cl.hpp:1689: undefined reference to `clGetPlatformInfo@20'
**Now, why does it say ``clGetPlatformInfo@20'is undefined?** In [this question][1], the answer seems to be that
-lOpenCLcomes before the source file. But in my case,
-lOpenCL` is the very last argument of the build line. On the other hand, I can't see that main.cpp is built anywhere, so what happens to that file?