Thread: Run openGl with Qt 4.8

  1. #1
    Registered User
    Join Date
    Nov 2016
    Posts
    26

    Run openGl with Qt 4.8

    Hi

    I write a simple program to run the opengl in the Qt 4.8.
    IDE: VS 2008 with Qt 4.8 Addin
    Included gl.h and QGLWidget
    I included all the lib in the Linker section
    (opengl32.lib glew32d.lib QtCore4.lib qtmain.lib)

    I am getting the below error


    1>myGLWidget.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QGLWidget::QGLWidget(class QWidget *,class QGLWidget const *,class QFlags<enum Qt::WindowType>)" (__imp_??0QGLWidget@@QAE@PAVQWidget@@PBV0@V?$QFlag s@W4WindowType@Qt@@@@@Z) referenced in function "public: __thiscall GLWidget::GLWidget(class QWidget *)" (??0GLWidget@@QAE@PAVQWidget@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall GLWidget::metaObject(void)const " (?metaObject@GLWidget@@UBEPBUQMetaObject@@XZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall GLWidget::qt_metacast(char const *)" (?qt_metacast@GLWidget@@UAEPAXPBD@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall GLWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@GLWidget@@UAEHW4Call@QMetaObject@@HP APAX@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QGLWidget::event(class QEvent *)" (?event@QGLWidget@@MAE_NPAVQEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QWidget::setVisible(bool)" (?setVisible@QWidget@@UAEX_N@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual class QSize __thiscall QWidget::sizeHint(void)const " (?sizeHint@QWidget@@UBE?AVQSize@@XZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual class QSize __thiscall QWidget::minimumSizeHint(void)const " (?minimumSizeHint@QWidget@@UBE?AVQSize@@XZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QWidget::heightForWidth(int)const " (?heightForWidth@QWidget@@UBEHH@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::mouseReleaseEvent(class QMouseEvent *)" (?mouseReleaseEvent@QWidget@@MAEXPAVQMouseEvent@@@ Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::mouseDoubleClickEvent(class QMouseEvent *)" (?mouseDoubleClickEvent@QWidget@@MAEXPAVQMouseEven t@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::wheelEvent(class QWheelEvent *)" (?wheelEvent@QWidget@@MAEXPAVQWheelEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::keyReleaseEvent(class QKeyEvent *)" (?keyReleaseEvent@QWidget@@MAEXPAVQKeyEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::focusInEvent(class QFocusEvent *)" (?focusInEvent@QWidget@@MAEXPAVQFocusEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::focusOutEvent(class QFocusEvent *)" (?focusOutEvent@QWidget@@MAEXPAVQFocusEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::enterEvent(class QEvent *)" (?enterEvent@QWidget@@MAEXPAVQEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::leaveEvent(class QEvent *)" (?leaveEvent@QWidget@@MAEXPAVQEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget:aintEvent(class QPaintEvent *)" (?paintEvent@QGLWidget@@MAEXPAVQPaintEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::moveEvent(class QMoveEvent *)" (?moveEvent@QWidget@@MAEXPAVQMoveEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::resizeEvent(class QResizeEvent *)" (?resizeEvent@QGLWidget@@MAEXPAVQResizeEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::closeEvent(class QCloseEvent *)" (?closeEvent@QWidget@@MAEXPAVQCloseEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::contextMenuEvent(class QContextMenuEvent *)" (?contextMenuEvent@QWidget@@MAEXPAVQContextMenuEve nt@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::tabletEvent(class QTabletEvent *)" (?tabletEvent@QWidget@@MAEXPAVQTabletEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::actionEvent(class QActionEvent *)" (?actionEvent@QWidget@@MAEXPAVQActionEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::dragEnterEvent(class QDragEnterEvent *)" (?dragEnterEvent@QWidget@@MAEXPAVQDragEnterEvent@@ @Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::dragMoveEvent(class QDragMoveEvent *)" (?dragMoveEvent@QWidget@@MAEXPAVQDragMoveEvent@@@Z )
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::dragLeaveEvent(class QDragLeaveEvent *)" (?dragLeaveEvent@QWidget@@MAEXPAVQDragLeaveEvent@@ @Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::dropEvent(class QDropEvent *)" (?dropEvent@QWidget@@MAEXPAVQDropEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::showEvent(class QShowEvent *)" (?showEvent@QWidget@@MAEXPAVQShowEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::hideEvent(class QHideEvent *)" (?hideEvent@QWidget@@MAEXPAVQHideEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QWidget::winEvent(struct tagMSG *,long *)" (?winEvent@QWidget@@MAE_NPAUtagMSG@@PAJ@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::changeEvent(class QEvent *)" (?changeEvent@QWidget@@MAEXPAVQEvent@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::inputMethodEvent(class QInputMethodEvent *)" (?inputMethodEvent@QWidget@@MAEXPAVQInputMethodEve nt@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QWidget::inputMethodQuery(enum Qt::InputMethodQuery)const " (?inputMethodQuery@QWidget@@UBE?AVQVariant@@W4Inpu tMethodQuery@Qt@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QWidget::focusNextPrevChild(bool)" (?focusNextPrevChild@QWidget@@MAE_N_N@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::styleChange(class QStyle &)" (?styleChange@QWidget@@MAEXAAVQStyle@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::enabledChange(bool)" (?enabledChange@QWidget@@MAEX_N@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget:aletteChange(class QPalette const &)" (?paletteChange@QWidget@@MAEXABVQPalette@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::fontChange(class QFont const &)" (?fontChange@QWidget@@MAEXABVQFont@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::windowActivationChange(bool)" (?windowActivationChange@QWidget@@MAEX_N@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::languageChange(void)" (?languageChange@QWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QGLWidget::updateGL(void)" (?updateGL@QGLWidget@@UAEXXZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QGLWidget::updateOverlayGL(void)" (?updateOverlayGL@QGLWidget@@UAEXXZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::initializeOverlayGL(void)" (?initializeOverlayGL@QGLWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::resizeOverlayGL(int,int)" (?resizeOverlayGL@QGLWidget@@MAEXHH@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget:aintOverlayGL(void)" (?paintOverlayGL@QGLWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::glInit(void)" (?glInit@QGLWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QGLWidget::glDraw(void)" (?glDraw@QGLWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QWidget::devType(void)const " (?devType@QWidget@@UBEHXZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual class QPaintEngine * __thiscall QGLWidget:aintEngine(void)const " (?paintEngine@QGLWidget@@UBEPAVQPaintEngine@@XZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual struct HDC__ * __thiscall QWidget::getDC(void)const " (?getDC@QWidget@@UBEPAUHDC__@@XZ)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QWidget::releaseDC(struct HDC__ *)const " (?releaseDC@QWidget@@UBEXPAUHDC__@@@Z)
    1>myGLWidget.obj : error LNK2001: unresolved external symbol "protected: virtual int __thiscall QWidget::metric(enum QPaintDevice::PaintDeviceMetric)const " (?metric@QWidget@@MBEHW4PaintDeviceMetric@QPaintDe vice@@@Z)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall QMouseEvent::x(void)const " (__imp_?x@QMouseEvent@@QBEHXZ) referenced in function "protected: virtual void __thiscall GLWidget::mouseMoveEvent(class QMouseEvent *)" (?mouseMoveEvent@GLWidget@@MAEXPAVQMouseEvent@@@Z)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall QMouseEvent::y(void)const " (__imp_?y@QMouseEvent@@QBEHXZ) referenced in function "protected: virtual void __thiscall GLWidget::mouseMoveEvent(class QMouseEvent *)" (?mouseMoveEvent@GLWidget@@MAEXPAVQMouseEvent@@@Z)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall QWidget::close(void)" (__imp_?close@QWidget@@QAE_NXZ) referenced in function "protected: virtual void __thiscall GLWidget::keyPressEvent(class QKeyEvent *)" (?keyPressEvent@GLWidget@@MAEXPAVQKeyEvent@@@Z)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall QKeyEvent::key(void)const " (__imp_?key@QKeyEvent@@QBEHXZ) referenced in function "protected: virtual void __thiscall GLWidget::keyPressEvent(class QKeyEvent *)" (?keyPressEvent@GLWidget@@MAEXPAVQKeyEvent@@@Z)
    1>E:\Remaining\C++_Practice\OpenGl_Practice\sample 1\Debug\sample1.exe : fatal error LNK1120: 64 unresolved externals


    Could you please help on what are the remaining libraries i need to mention in order to run opengl in the qt successfully

  2. #2
    Registered User
    Join Date
    Nov 2016
    Posts
    26
    Now I am getting the error message like the below
    (Linker library QtOpenGLd4.libglew32d.lib
    qtmaind.lib
    QtCored4.lib
    QtDeclaratived4.lib
    QtGuid4.lib
    QtNetworkd4.lib)



    1>Compiling...
    1>main.cpp
    1>myGLWidget.cpp
    1>Generating Code...
    1>Compiling manifest to resources...
    1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
    1>Copyright (C) Microsoft Corporation. All rights reserved.
    1>Linking...
    1>myGLWidget.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function "protected: virtual void __thiscall GLWidget::initializeGL(void)" (?initializeGL@GLWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol __imp__glBlendFunc@8 referenced in function "protected: virtual void __thiscall GLWidget::initializeGL(void)" (?initializeGL@GLWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function "protected: virtual void __thiscall GLWidget::initializeGL(void)" (?initializeGL@GLWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol __imp__glDisable@4 referenced in function "protected: virtual void __thiscall GLWidget::initializeGL(void)" (?initializeGL@GLWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "protected: virtual void __thiscall GLWidget::resizeGL(int,int)" (?resizeGL@GLWidget@@MAEXHH@Z)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function "protected: virtual void __thiscall GLWidget::resizeGL(int,int)" (?resizeGL@GLWidget@@MAEXHH@Z)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function "protected: virtual void __thiscall GLWidget::resizeGL(int,int)" (?resizeGL@GLWidget@@MAEXHH@Z)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "protected: virtual void __thiscall GLWidget:aintGL(void)" (?paintGL@GLWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol __imp__glVertex2f@8 referenced in function "protected: virtual void __thiscall GLWidget:aintGL(void)" (?paintGL@GLWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function "protected: virtual void __thiscall GLWidget:aintGL(void)" (?paintGL@GLWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol __imp__glColor3f@12 referenced in function "protected: virtual void __thiscall GLWidget:aintGL(void)" (?paintGL@GLWidget@@MAEXXZ)
    1>myGLWidget.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function "protected: virtual void __thiscall GLWidget:aintGL(void)" (?paintGL@GLWidget@@MAEXXZ)
    1>E:\Remaining\C++_Practice\OpenGl_Practice\sample 1\Debug\sample1.exe : fatal error LNK1120: 12 unresolved externals
    1>Build log was saved at "file://e:\Remaining\C++_Practice\OpenGl_Practice\sample1\ Debug\BuildLog.htm"

  3. #3
    Registered User
    Join Date
    Nov 2016
    Posts
    26
    Could any of you help me on what are the libraries i have to include in the Linker part in order to run the opengl with qt.
    IDE : 2008
    Plugin Qt 4.8

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    No idea about the compiler you are using; but, with GCC Compiler the order of the libraries in the link list matters.

    Edit1:
    From glClearColor function (Windows)

    glClearColor function is in Library Opengl32.lib

    Tim S.
    Last edited by stahta01; 04-07-2017 at 10:27 AM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    That's a good question about link order on Windows :P

    I think the general rule of thumb was simply that you need your import statements before your export statements.

    Fortunately though, vcpkg supports both OpenGL and Qt so you can use that to install both of those libraries which create the import libs for you so there's no manual DLL linking required.

    But if you already have the import libs and everything like that squared away, it might help us to see how you're compiling your code. I don't think I saw any direct linking commands in your posts.


    IDE: VS 2008 with Qt 4.8 Addin
    Also, whoa O_o

    There seems like there's much more modern versions of the IDE available too. vcpkg + CMake is a really nice combo for building stuff on Windows now too.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tic Tac Toe OpenGL
    By atomicrockerdud in forum C Programming
    Replies: 0
    Last Post: 05-01-2012, 03:34 PM
  2. Replies: 3
    Last Post: 09-02-2010, 01:26 PM
  3. OpenGL Quesiton: Does Windows XP, Vista still at OpenGL 1.1?
    By indigo0086 in forum Game Programming
    Replies: 8
    Last Post: 05-21-2007, 11:18 AM
  4. Replies: 5
    Last Post: 02-12-2006, 08:42 PM
  5. OpenGL, texturing...and...more OpenGL
    By Sunny in forum Game Programming
    Replies: 2
    Last Post: 07-08-2002, 02:34 PM

Tags for this Thread