title: How to compile a simple OpenCL application with Qt Creator?
body: <p>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:</p>
  
  <pre><code>#include &lt;utility&gt;
  #define __NO_STD_VECTOR // Use cl::vector instead of STL version
  #include &lt;CL/cl.hpp&gt;
  
  int main()
  {
      return 0;
  }
  </code></pre>
  
  <p>and here is my .pro file:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I had to remove <code>$$PWD/</code> (which Qt Creator added to the beginning of each path for some unknown reason) in <code>INCLUDEPATH</code>, otherwise the compiler wouldn't find <code>CL/cl.cpp</code>.</p>
  
  <p>Anyway, when trying to compile, I get the following error message:</p>
  
  <pre><code>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
   {
   ^
  </code></pre>
  
  <p>followed by a lot of other error messages. <strong>Why do I get these errors and how do I resolve them?</strong></p>
  
  <hr>
  
  <h2>Update 1</h2>
  
  <p>As prajmus pointed out in a comment, <code>$$PWD</code> is the directory of the .pro file, and hence a space is missing after it, which Qt Creator missed to put there. In the <code>LIBS</code> specification, <code>-L</code> also has to be added before <code>C:</code>.</p>
  
  <p>I fixed that, but I still get the same error message.</p>
  
  <hr>
  
  <h2>Update 2</h2>
  
  <p>If I comment out the line <code>#define __NO_STD_VECTOR</code>, the error messages disappear, but instead I get</p>
  
  <pre><code>c:/program1/qt/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lOpenCLd
  </code></pre>
  
  <p>Changing <code>-lOpenCLd</code> to <code>-lOpenCL</code> gets rid of that warning, but instead gives me</p>
  
  <pre><code>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'
  </code></pre>
  
  <p>**Now, why does it say ``clGetPlatformInfo@20'<code>is undefined?** In [this question][1], the answer seems to be that</code>-lOpenCL<code>comes before the source file. But in my case,</code>-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?</p>