Results 1 to 4 of 4

Thread: OpenGL problem on msvc2008 in release

  1. #1
    Join Date
    Sep 2008
    Posts
    11
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default OpenGL problem on msvc2008 in release

    Hi i have a bit of a problem. I want to use opengl in my program. I've added

    Qt Code:
    1. CONFIG += qt thread warn_off debug_and_release build_all
    2. QT += qt3support opengl
    To copy to clipboard, switch view to plain text mode 

    to my .pro file. And i create a simple class derived from QGLWidget

    Qt Code:
    1. #include <QGLWidget>
    2.  
    3.  
    4. class MyOpenGL : public QGLWidget
    5. {
    6. Q_OBJECT
    7. public:
    8. MyOpenGL(QWidget *parent = 0, QGLWidget *shareWidget = 0);
    9. ~MyOpenGL(void);
    10.  
    11. protected:
    12. void paintEvent(QPaintEvent *event);
    13. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "MyOpenGL.h"
    2. #include <QtGui>
    3. #include <QtOpenGL>
    4.  
    5. MyOpenGL::MyOpenGL(QWidget *parent, QGLWidget *shareWidget)
    6. : QGLWidget(parent, shareWidget)
    7. {
    8. setFixedSize(200, 200);
    9. setAutoFillBackground(false);
    10. }
    11.  
    12. MyOpenGL::~MyOpenGL(void)
    13. {
    14. }
    15.  
    16. void MyOpenGL::paintEvent(QPaintEvent *event)
    17. {
    18. }
    To copy to clipboard, switch view to plain text mode 

    Nothing fancy. Now everything works fine in debug mode. However when i switch to release mode, the project compiles and runs to the point where i try to instantiate MyOpenGL class. At that point program crashes with the message from Qt:

    "Cannot mix incompatible Qt libraries"

    I have only Qt4.3.3 installed on my machine and i develop in msvc2008 on WinXP SP3. I'm quite puzzled by this. Since it runs fine in debug and crashed in release would suggest that there is something fishy with the project setup, but i can't find anything wrong with it. Everything looks ok.

    I'll appreciate any thoughts on what could be the cause of this problem.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: OpenGL problem on msvc2008 in release

    Run Dependency Walker on your executable and see where is looks for Qt libraries. Maybe it takes QtOpenGL from a different location.

  3. The following user says thank you to jacek for this useful post:

    redoctober0 (6th February 2009)

  4. #3
    Join Date
    Sep 2008
    Posts
    11
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: OpenGL problem on msvc2008 in release

    Thanks for the tip jacek!

    It turns out that i have MiKTex installed (a Latex program) which comes with its own set of QtCore4.dll and QtGui4.dll and the path to it is written in the PATH env variable. In addition, the path to MiKTeX libs preceded the path to QT's libs in the PATH list. So when it was linking in debug it would look in MiKTeX directory for debug version of QT libs wouldn't find them and move on to the QT directory. But in release mode it would find the libs in the MiKTex directory and load them up and then when it tried to load QtOpenGL4.dll from Qt directory it wouldn't match with core libs.

    Now all i did was change the order of the paths in the PATH variable so the QT path is first in the list and everything seems to work just fine.

    Just a quick follow up then. Is that the best solution for this problem or there's something more elegant?

    So thanks again for the tip.

    Cheers.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: OpenGL problem on msvc2008 in release

    Quote Originally Posted by redoctober0 View Post
    Is that the best solution for this problem or there's something more elegant?
    This is a well-known problem called "DLL hell". The safest solution is to keep all libraries you need in the same directory as the executable, but of course it ruins the whole concept of shared libraries.

Similar Threads

  1. Qt Embedded + OpenGL problem
    By EeroS in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 7th October 2008, 15:32
  2. problem in rendering opengl on QGraphicsView
    By Sandip in forum Qt Programming
    Replies: 17
    Last Post: 15th April 2008, 09:27
  3. Problem when mixing openGL and QPainter
    By sanjayshelke in forum Qt Programming
    Replies: 9
    Last Post: 21st March 2008, 13:49
  4. problem with opengl, zooming, drawpixels, and origin
    By ntp in forum General Programming
    Replies: 0
    Last Post: 22nd February 2008, 22:48
  5. Problem with Release version
    By jlbrd in forum Installation and Deployment
    Replies: 7
    Last Post: 30th March 2006, 20:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.