title: QT OpenGL Link Error
body: <p>I have encountered an error while compiling an OpenGL QT project in QT Creator on Windows.</p>
  
  <p>The error I am getting is a link error.  </p>
  
  <p>I have tried re-running qmake, followed by a clean, and build, but this did not solve the issue.  I have also tried some of the other suggestions from stackoverflow questions similar to mine but none resolve this issue</p>
  
  <p>I will include the link error and my project code below.</p>
  
  <p>Thanks in advance!</p>
  
  <p>link errors:</p>
  
  <pre><code>17:38:04: Running steps for project OpenGL2...
  17:38:04: Configuration unchanged, skipping qmake step.
  17:38:04: Starting: "C:\Qt\Tools\QtCreator\bin\jom.exe" 
      C:\Qt\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
      C:\Qt\5.6\msvc2013_64\bin\uic.exe ..\mainwindow.ui -o ui_mainwindow.h
      cl -c -nologo -Zc:wchar_t -FS -Zi -MDd -GR -W3 -w34100 -w34189 -w44996 -EHsc /Fddebug\OpenGL2.pdb -DUNICODE -DWIN32 -DWIN64 -DQT_QML_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\..\OpenGL2 -I. -IC:\Qt\5.6\msvc2013_64\include -IC:\Qt\5.6\msvc2013_64\include\QtOpenGL -IC:\Qt\5.6\msvc2013_64\include\QtWidgets -IC:\Qt\5.6\msvc2013_64\include\QtGui -IC:\Qt\5.6\msvc2013_64\include\QtANGLE -IC:\Qt\5.6\msvc2013_64\include\QtCore -Idebug -I. -IC:\Qt\5.6\msvc2013_64\mkspecs\win32-msvc2013 -Fodebug\ @C:\Users\context\AppData\Local\Temp\main.obj.9848.16.jom
      cl -c -nologo -Zc:wchar_t -FS -Zi -MDd -GR -W3 -w34100 -w34189 -w44996 -EHsc /Fddebug\OpenGL2.pdb -DUNICODE -DWIN32 -DWIN64 -DQT_QML_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\..\OpenGL2 -I. -IC:\Qt\5.6\msvc2013_64\include -IC:\Qt\5.6\msvc2013_64\include\QtOpenGL -IC:\Qt\5.6\msvc2013_64\include\QtWidgets -IC:\Qt\5.6\msvc2013_64\include\QtGui -IC:\Qt\5.6\msvc2013_64\include\QtANGLE -IC:\Qt\5.6\msvc2013_64\include\QtCore -Idebug -I. -IC:\Qt\5.6\msvc2013_64\mkspecs\win32-msvc2013 -Fodebug\ @C:\Users\context\AppData\Local\Temp\mainwindow.obj.9848.32.jom
      C:\Qt\5.6\msvc2013_64\bin\moc.exe -DUNICODE -DWIN32 -DWIN64 -DQT_QML_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1800 -D_WIN32 -D_WIN64 -IC:/Qt/5.6/msvc2013_64/mkspecs/win32-msvc2013 -IC:/Users/context/Documents/OpenGL2 -IC:/Qt/5.6/msvc2013_64/include -IC:/Qt/5.6/msvc2013_64/include/QtOpenGL -IC:/Qt/5.6/msvc2013_64/include/QtWidgets -IC:/Qt/5.6/msvc2013_64/include/QtGui -IC:/Qt/5.6/msvc2013_64/include/QtANGLE -IC:/Qt/5.6/msvc2013_64/include/QtCore -I. ..\mainwindow.h -o debug\moc_mainwindow.cpp
  main.cpp
  mainwindow.cpp
  ..\mainwindow.cpp(3) : warning C4100: 'parent' : unreferenced formal parameter
  ..\mainwindow.cpp(28) : warning C4100: 'h' : unreferenced formal parameter
  ..\mainwindow.cpp(28) : warning C4100: 'w' : unreferenced formal parameter
  ..\mainwindow.cpp(52) : warning C4100: 'event' : unreferenced formal parameter
  ..\mainwindow.cpp(57) : warning C4100: 'event' : unreferenced formal parameter
      cl -c -nologo -Zc:wchar_t -FS -Zi -MDd -GR -W3 -w34100 -w34189 -w44996 -EHsc /Fddebug\OpenGL2.pdb -DUNICODE -DWIN32 -DWIN64 -DQT_QML_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\..\OpenGL2 -I. -IC:\Qt\5.6\msvc2013_64\include -IC:\Qt\5.6\msvc2013_64\include\QtOpenGL -IC:\Qt\5.6\msvc2013_64\include\QtWidgets -IC:\Qt\5.6\msvc2013_64\include\QtGui -IC:\Qt\5.6\msvc2013_64\include\QtANGLE -IC:\Qt\5.6\msvc2013_64\include\QtCore -Idebug -I. -IC:\Qt\5.6\msvc2013_64\mkspecs\win32-msvc2013 -Fodebug\ @C:\Users\context\AppData\Local\Temp\moc_mainwindow.obj.9848.718.jom
  moc_mainwindow.cpp
      link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\OpenGL2.exe @C:\Users\context\AppData\Local\Temp\OpenGL2.exe.9848.4400.jom
  
  **mainwindow.obj : error LNK2019: unresolved external symbol __imp_glBegin referenced in function "protected: virtual void __cdecl MainWindow::paintGL(void)" (?paintGL@MainWindow@@MEAAXXZ)
  mainwindow.obj : error LNK2019: unresolved external symbol __imp_glClear referenced in function "protected: virtual void __cdecl MainWindow::paintGL(void)" (?paintGL@MainWindow@@MEAAXXZ)
  mainwindow.obj : error LNK2019: unresolved external symbol __imp_glClearColor referenced in function "protected: virtual void __cdecl MainWindow::paintGL(void)" (?paintGL@MainWindow@@MEAAXXZ)
  mainwindow.obj : error LNK2019: unresolved external symbol __imp_glEnd referenced in function "protected: virtual void __cdecl MainWindow::paintGL(void)" (?paintGL@MainWindow@@MEAAXXZ)
  mainwindow.obj : error LNK2019: unresolved external symbol __imp_glFlush referenced in function "protected: virtual void __cdecl MainWindow::paintGL(void)" (?paintGL@MainWindow@@MEAAXXZ)
  mainwindow.obj : error LNK2019: unresolved external symbol __imp_glVertex2f referenced in function "protected: virtual void __cdecl MainWindow::paintGL(void)" (?paintGL@MainWindow@@MEAAXXZ)
  debug\OpenGL2.exe : fatal error LNK1120: 6 unresolved externals
  jom: C:\Users\context\Documents\OpenGL2\build\Makefile.Debug [debug\OpenGL2.exe] Error 1120**
  jom: C:\Users\context\Documents\OpenGL2\build\Makefile [debug] Error 2
  17:38:09: The process "C:\Qt\Tools\QtCreator\bin\jom.exe" exited with code 2.
  Error while building/deploying project OpenGL2 (kit: Desktop Qt 5.6.1 MSVC2013 64bit2)
  When executing step "Make"
  </code></pre>
  
  <p>Here is my code and configuration files:</p>
  
  <p>OpenGL2.pro</p>
  
  <pre><code>QT       += core gui opengl
  
  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  
  TARGET = OpenGL2
  TEMPLATE = app
  
  
  SOURCES += main.cpp\
          mainwindow.cpp
  
  HEADERS  += mainwindow.h
  
  FORMS    += mainwindow.ui
  </code></pre>
  
  <p>mainwindow.h</p>
  
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QOpenGLWindow&gt;
  
  #include &lt;QSurfaceFormat&gt;
  #include &lt;QOpenGLFunctions&gt;
  
  #include &lt;QtOpenGL&gt;
  #include &lt;GL/glu.h&gt;
  
  class MainWindow : public QOpenGLWindow
  {
      Q_OBJECT
  
  public:
      explicit MainWindow(QWidget *parent = 0);
      ~MainWindow();
  
  protected:
      virtual void initializeGL();
      virtual void resizeGL(int w, int h);
      virtual void paintGL();
  
      void paintEvent(QPaintEvent *event);
      void resizeEvent(QResizeEvent *event);
  
  private:
      QOpenGLContext* context;
      QOpenGLFunctions* openGLFunctions;
  
  };
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre><code>#include "mainwindow.h"
  #include &lt;QApplication&gt;
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      MainWindow w;
      w.setTitle("OpenGL Hello World!");
      w.resize(640, 480);
      w.show();
  
      return a.exec();
  }
  </code></pre>
  
  <p>mainwindow.cpp</p>
  
  <pre><code>#include "mainwindow.h"
  
  MainWindow::MainWindow(QWidget *parent)
  {
      setSurfaceType(QWindow::OpenGLSurface);
  
      QSurfaceFormat format;
      format.setProfile(QSurfaceFormat::CompatibilityProfile);
      format.setVersion(2, 1); // OpenGL 2.1
      setFormat(format);
  
      context = new QOpenGLContext;
      context-&gt;setFormat(format);
      context-&gt;create();
      context-&gt;makeCurrent(this);
  
      openGLFunctions = context-&gt;functions();
  }
  
  MainWindow::~MainWindow()
  {
  }
  
  void MainWindow::initializeGL()
  {
  }
  
  void MainWindow::resizeGL(int w, int h)
  {
  }
  
  void MainWindow::paintGL()
  {
      // Initialize clear color (cornflower blue)
      glClearColor(0.39f, 0.58f, 0.93f, 1.f);
  
      // Clear color buffer
      glClear(GL_COLOR_BUFFER_BIT);
  
      // Hello World
      // Render quad
      glBegin(GL_QUADS);
          glVertex2f(-0.5f, -0.5f);
          glVertex2f(0.5f, -0.5f);
          glVertex2f(0.5f, 0.5f);
          glVertex2f(-0.5f, 0.5f);
      glEnd();
  
      glFlush();
  }
  
  void MainWindow::paintEvent(QPaintEvent *event)
  {
      paintGL();
  }
  
  void MainWindow::resizeEvent(QResizeEvent *event)
  {
  }
  </code></pre>