Results 1 to 8 of 8

Thread: Cannot build diagram example under Windows 7,incomplete QGraphicsItem ckass

  1. #1
    Join Date
    Dec 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy Re: Cannot build diagram example under Windows 7,incomplete QGraphicsItem ckass

    This is my first time with Qt and I am trying to build the Diagram example from chapter 8 of 'C++ Gui Programming with Qt 4'. I am using 32 bit Windows 7 with the latest Qt just downloaded, open source model. I have Cygwin with mingw. I installed Qt in the usual way using the installer with all defaults selected.

    The first problem I had was that qmake produced a Makefile.Debug that referenced -lmingw32 without also including <qt>/mingw/lib in the library search path. This caused the link step to fail with undefined library mingw32. I fixed this by adding

    LIBS += -L'C:/Qt/2010.05/mingw/lib' -lmingw32

    to the end of diagram.pro. Now the link step complains about incomplete classes in QtGui, specifically QGraphicsItem. Here is the output from the link step:

    g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug/diagram.exe debug/diagramwindow.o debug/link.o debug/main.o debug/node.o debug/propertiesdialog.o debug/moc_diagramwindow.o debug/moc_propertiesdialog.o debug/qrc_resources.o -L'c:/Qt/2010.05/qt/lib' -lmingw32 -lqtmaind -LC:/Qt/2010.05/mingw/lib -lmingw32 -lQtGuid4 -lQtCored4
    debug/diagramwindow.o:/home/aheirich/Desktop/editor/diagram/diagramwindow.cpp:275: undefined reference to `typeinfo for QGraphicsItem'
    debug/diagramwindow.o:/home/aheirich/Desktop/editor/diagram/diagramwindow.cpp:265: undefined reference to `typeinfo for QGraphicsItem'
    debug/diagramwindow.o:/home/aheirich/Desktop/editor/diagram/diagramwindow.cpp:285: undefined reference to `typeinfo for QGraphicsItem'
    debug/diagramwindow.o:/home/aheirich/Desktop/editor/diagram/diagramwindow.cpp:286: undefined reference to `typeinfo for QGraphicsItem'
    debug/diagramwindow.o:/home/aheirich/Desktop/editor/diagram/diagramwindow.cpp:57: undefined reference to `typeinfo for QGraphicsItem'
    debug/link.o:link.cpp.rdata$_ZTI4Link typeinfo for Link]+0x8): undefined reference to `typeinfo for QGraphicsLineItem'
    ...


    The undefined reference to 'typeinfo for c' means that class c contains virtual functions for which no definitions were found. I looked inside class QGraphicsItem and it certainly has many non-pure virtual functions so this may be true. I did not try to match up the definitions in QGraphicsItem.cpp so I didn't identify which functions were at fault. This simply should not be happening, or everyone would be having this problem using QGraphicsItem????

    Is this a known problem? A problem only under Windows 7?


    Added after 8 minutes:


    Some further info. I tried #including each of the missing classes in the source files referred to in the error messages, for example in diagramwindow.cpp I added
    #include <QGraphicsItem>
    This did not solve the problem.


    Added after 50 minutes:


    Just to factor things further: I eliminated most of the contents of diagramwindow.cpp as shown below. This removes the diagram example from being a factor, this simply invokes a Qt class in a dynamic_cast. The error messages correspond to the two dynamic_cast statements below:

    Qt Code:
    1. #include <QGraphicsItem>
    2. #include <QtGui>
    3.  
    4. #include "diagramwindow.h"
    5. #include "link.h"
    6. #include "node.h"
    7. #include "propertiesdialog.h"
    8.  
    9. #if 0
    10. ...
    11. #endif////remove this
    12.  
    13. DiagramWindow::NodePair DiagramWindow::selectedNodePair() const
    14. {
    15. QList<QGraphicsItem *> items = scene->selectedItems();
    16. if (items.count() == 2) {
    17. Node *first = dynamic_cast<Node *>(items.first());
    18. Node *second = dynamic_cast<Node *>(items.last());
    19. if (first && second)
    20. return NodePair(first, second);
    21. }
    22. return NodePair();
    23. }
    To copy to clipboard, switch view to plain text mode 

    The example seems to show that you cannot use a QGraphicsItem * in a dynamic_cast,but this seems impossible for two reasons: 1. it means that QtGui is fundamentally broken; 2. this diagram example presumably used to work under Qt 4 (since it is included with the book for Qt 4).
    Last edited by aheirich; 18th December 2010 at 05:38.

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Cannot build diagram example under Windows 7,incomplete QGraphicsItem ckass

    Try using qgraphicsitem_cast<>() instead of dynamic cast. This seems an rtti issue to me.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

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

    Default Re: Cannot build diagram example under Windows 7,incomplete QGraphicsItem ckass

    I'd say you built Qt without rtti support.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Dec 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Cannot build diagram example under Windows 7,incomplete QGraphicsItem ckass

    I didn't build Qt, I installed it from the download. I'll have to read about rtti.
    thanks

  5. #5
    Join Date
    Dec 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Cannot build diagram example under Windows 7,incomplete QGraphicsItem ckass

    update: the problem is definitely that the Open Source version of Qt on Windows is built without rtti support. There is no way to build the example program (chapter 8 diagram) without rtti. So I tried to build Qt from sources on windows. What a disaster. Suffice it to save I will save you a couple of paragraphs to conclude that I have given up on the Open Source Qt for Windows, it is not quality-assured enough. Building it doesn't work, in myriad ways. And without rtti I cannot use it.

    On to the mac. But I am having problems there too! But that is another thread.


    Added after 37 minutes:


    All is well on the Mac, so I will continue work there. Windows has too many problems.
    Last edited by aheirich; 19th December 2010 at 05:38.

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

    Default Re: Cannot build diagram example under Windows 7,incomplete QGraphicsItem ckass

    Quote Originally Posted by aheirich View Post
    So I tried to build Qt from sources on windows. What a disaster. Suffice it to save I will save you a couple of paragraphs to conclude that I have given up on the Open Source Qt for Windows, it is not quality-assured enough. Building it doesn't work, in myriad ways. And without rtti I cannot use it.
    I will have to check that but I think rtti should be enabled by default. As for building Qt, I have never had any serious problems with it. Maybe if you tell us what is wrong, we would be able to help you.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Dec 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Cannot build diagram example under Windows 7,incomplete QGraphicsItem ckass

    Well, I found that many problems were because I was trying to build under Cygwin. I didn't know about the mingw32 prompt. Right now it is building for me, keep fingers crossed. Then I will see if I can build the diagram example.

  8. #8
    Join Date
    Dec 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Cannot build diagram example under Windows 7,incomplete QGraphicsItem ckass

    Yes it builds the example and it runs. Thanks to mingw32.

Similar Threads

  1. Can't build qwt in Windows
    By MattPhillips in forum Qwt
    Replies: 2
    Last Post: 26th December 2009, 16:18
  2. Build Qt in Windows
    By graciano in forum Installation and Deployment
    Replies: 2
    Last Post: 12th May 2009, 12:51
  3. Replies: 3
    Last Post: 28th December 2007, 11:02
  4. Cant build exe in windows
    By drinu21 in forum Qt Programming
    Replies: 3
    Last Post: 13th November 2007, 16:11
  5. Replies: 10
    Last Post: 25th February 2007, 00:23

Tags for this Thread

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.