Results 1 to 7 of 7

Thread: Qt4 Lib -- Linker Problems Qt4/OpenGL

  1. #1
    Join Date
    Jan 2009
    Location
    N 38d 51.9m W 104d 47.5m
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Qt4 Lib -- Linker Problems Qt4/OpenGL

    Hello, Everyone,
    I've got a perplexing problem. I'm following the Qt4 tutorials of interest and while working with the "Hello GL" example ( here ), I'm getting some linker problems that I can't figure out.

    I'm using Fedora 10. I'm using monodevelop to type in the code (no abuse please from you IDE-haters! ) and I'm sure that part of the problem is that it doesn't add everything to the qmake Makefile. I'm not 100% familiar with Makefile generation, syntax, etc, but I can noodle out some of the important bits.

    Here's the rundown. The errors I'm getting point to a linker error. From what I've been able to determine, I'm either missing or not pointing at the proper qtlib(s). I just can't seem to figure out which ones they are. Here are some of the errors I'm getting:
    Qt Code:
    1. glwidget.o: In function `GLWidget::InitGL()':
    2. glwidget.cpp:(.text+0x930): undefined reference to `QGLWidget::qglClearColor(QColor const&) const'
    To copy to clipboard, switch view to plain text mode 
    And
    Qt Code:
    1. glwidget.o: In function `GLWidget::~GLWidget()':
    2. glwidget.cpp:(.text+0xbe0): undefined reference to `QGLWidget::makeCurrent()'
    To copy to clipboard, switch view to plain text mode 
    Etc.

    Also this one's a head scratcher to me as well:
    Qt Code:
    1. moc_glwidget.o:(.rodata._ZTV8GLWidget[vtable for GLWidget]+0x1c): undefined reference to `QGLWidget::event(QEvent*)'
    To copy to clipboard, switch view to plain text mode 

    I saw (on this forum, actually, which is why I'm posting here) this thread:
    Can't compile custom class derived from QGLWidget

    I tried this suggestion and it does indeed build, but I get this when I try to run the applicaion:
    Qt Code:
    1. X Error: BadRequest (invalid request code or no such operation) 1
    2. Extension: 143 (Uknown extension)
    3. Minor opcode: 19 (Unknown request)
    4. Resource id: 0x17
    5. qt-opengl: xcb_io.c:461: _XRead: Assertion `dpy->xcb->reply_data != 0' failed.
    6. Aborted
    To copy to clipboard, switch view to plain text mode 
    I don't know what this was supposed to do exactly; but it seemed to fix the 'unresolved externals' problem (yes, I learned dev on Windows/Visual Studio, don't hold it against me! )

    Here's the LIBS section of my Makefile.
    Qt Code:
    1. LIBS = $(SUBLIBS) -L/usr/local/Trolltech/Qt-4.4.3/lib -lQtGui -L/usr/l
    2. ocal/Trolltech/Qt-4.4.3/lib -L/usr/X11R6/lib -pthread -lpng -lSM -lICE -pthread
    3. -pthread -lXi -lXrender -lXrandr -lfreetype -lfontconfig -lXext -lX11 -lQtCore -
    4. lz -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread
    To copy to clipboard, switch view to plain text mode 
    to which I (manually add) '-L/usr/lib -lGL' to clear the errors like this:
    Qt Code:
    1. glwidget.o: In function `GLWidget::MakeObject()':
    2. glwidget.cpp:(.text+0x33c): undefined reference to `glGenLists'
    To copy to clipboard, switch view to plain text mode 

    I know there's a lot here, and that I'm asking several questions, but are there any suggestions for making this all work? I'm fairly new to the subtleties of development on Linux, though not new to development.

    (As an aside, if there's a really good, step by step Makefile tutorial around, point me in the right direction. Most of them I've seen seem to presume some familiarity with them... I want a "this is a mouse this a monitor" level).
    Last edited by Jackson.Shredder; 17th January 2009 at 22:50.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt4 Lib -- Linker Problems Qt4/OpenGL

    Regardless of what IDE you use, you can use qmake to generate makefiles for your project. To use OpenGL all you need to do is to add QT+=opengl and rerun qmake.

  3. #3
    Join Date
    Jan 2009
    Location
    N 38d 51.9m W 104d 47.5m
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 Lib -- Linker Problems Qt4/OpenGL

    Quote Originally Posted by wysota View Post
    Regardless of what IDE you use, you can use qmake to generate makefiles for your project. To use OpenGL all you need to do is to add QT+=opengl and rerun qmake.

    Thanks, I appreciate the response; however, as I mentioned, that produces another problem:

    Quote Originally Posted by Jackson.Shredder View Post
    I saw (on this forum, actually, which is why I'm posting here) this thread:
    Can't compile custom class derived from QGLWidget

    I tried this suggestion and it does indeed build, but I get this when I try to run the applicaion:
    Qt Code:
    1. X Error: BadRequest (invalid request code or no such operation) 1
    2. Extension: 143 (Uknown extension)
    3. Minor opcode: 19 (Unknown request)
    4. Resource id: 0x17
    5. qt-opengl: xcb_io.c:461: _XRead: Assertion `dpy->xcb->reply_data != 0' failed.
    6. Aborted
    To copy to clipboard, switch view to plain text mode 
    I did run qmake after adding the "QT += opengl" to the .pro file.

    After some more digging around on the internet and in forums, I saw that '-opengl' was a ./configure option. I didn't build it with this option initially, so I figured I'd re-install Qt4 and explicitly building it with the "-opengl" option.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt4 Lib -- Linker Problems Qt4/OpenGL

    OpenGL support is enabled by default provided your system allows it. Enabling it explicitly won't make a difference. From what I see you experience a run-time error from the X server, so either OpenGL support in your system is broken or you do something weird in your application. The problem is surely unrelated to the process of compilation.

  5. #5
    Join Date
    Jan 2009
    Location
    N 38d 51.9m W 104d 47.5m
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 Lib -- Linker Problems Qt4/OpenGL

    Quote Originally Posted by wysota View Post
    OpenGL support is enabled by default provided your system allows it. Enabling it explicitly won't make a difference. From what I see you experience a run-time error from the X server, so either OpenGL support in your system is broken or you do something weird in your application. The problem is surely unrelated to the process of compilation.
    wysota, you're almost certainly correct. I continued to dig at this problem and here's what I found.

    The rpmfusion drivers are not completed for Fedora 10 and hence not released as yet. This wasn't news; however, intitially I didn't think this would matter: the proprietary ATI drivers seemed to fix the problem of my screen resolution. What I didn't put together was a crash I was getting whenever I tried using Open Office Writer (or any other OO application).

    Apprently, the drivers released by ATI weren't sufficiently compatible with Fedora 10. I've gone back to Fedora 9, which does seem to work ( glxgears runs fine), but am getting artifacts:


    I realize this may not be caused by Qt; however, I also believe I can't be the first to encounter this. While I plan to continue digging around at this until I get it working, any further suggestions, thoughts, and ideas would be appreciated.

    Thanks for everything so far.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt4 Lib -- Linker Problems Qt4/OpenGL

    Please don't use 3rd party sites for image storage, we really don't like it.

    I can't help you with your application without seeing any code My guess is that your paintGL() is messed up.

  7. #7
    Join Date
    Jan 2009
    Location
    N 38d 51.9m W 104d 47.5m
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 Lib -- Linker Problems Qt4/OpenGL

    No problem; what do you do for pics instead then?

    Okay, the PaintGL method:
    Qt Code:
    1. void GLWidget::PaintGL() {
    2. glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    3. glLoadIdentity();
    4. glTranslated( 0.0, 0.0, -10.0 );
    5. glRotated( ( xRot / 16.0 ), 1.0, 0.0, 0.0 );
    6. glRotated( ( yRot / 16.0 ), 0.0, 1.0, 0.0 );
    7. glRotated( ( zRot / 16.0 ), 0.0, 0.0, 1.0 );
    8. glCallList( object );
    9. }
    To copy to clipboard, switch view to plain text mode 

    I'm fairly certain it's not messed up.

    Apparently, I'm allowed to only upload five files. If you'd like the Makefile and/or the .pro file, let me know.
    Attached Files Attached Files

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.