Thread: qt help

  1. #1
    Unregistered
    Guest

    Thumbs down qt help

    Why is it when I try to compile this program from a qt tutorial

    Code:
    #include <qapplication.h>
    #include <qpushbutton.h>
    int main( int argc, char **argv )
    {
        QApplication a( argc, argv );     QPushButton hello( "Hello world!", 0 );
        hello.resize( 100, 30 );     a.setMainWidget( &hello );
        hello.show();
        return a.exec();
    }


    I compile it by typing

    [barrie@localhost barrie]$ g++ -I/usr/local/qt/include test.cpp

    I then get this output.


    ***********************
    ***********************


    /tmp/ccxDBCSi.o: In function `main':
    /tmp/ccxDBCSi.o(.text+0x1a): undefined reference to `QApplication::QApplication(int &, char **)' /tmp/ccxDBCSi.o(.text+0x31): undefined reference to `QString::QString(char const *)'
    /tmp/ccxDBCSi.o(.text+0x4d): undefined reference to `QPushButton::QPushButton(QString const &, QWidget *, char const *)'
    /tmp/ccxDBCSi.o(.text+0x83): undefined reference to `QPushButton::resize(int, int)'
    /tmp/ccxDBCSi.o(.text+0x99): undefined reference to `QApplication::setMainWidget(QWidget *)'
    /tmp/ccxDBCSi.o(.text+0xab): undefined reference to `QWidget::show(void)'
    /tmp/ccxDBCSi.o(.text+0xba): undefined reference to `QApplication::exec(void)'
    /tmp/ccxDBCSi.o(.text+0xd0): undefined reference to `QPushButton::~QPushButton(void)'
    /tmp/ccxDBCSi.o(.text+0xe1): undefined reference to `QApplication::~QApplication(void)'
    /tmp/ccxDBCSi.o(.text+0x12d): undefined reference to `QPushButton::~QPushButton(void)'
    /tmp/ccxDBCSi.o(.text+0x140): undefined reference to `QApplication::~QApplication(void)'
    /tmp/ccxDBCSi.o(.rodata+0x108): undefined reference to `QDropEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QMemArray<char> type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tft9QMemArray1Zc+0x10 ): undefined reference to `QGArray type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tft9QMemArray1Zc+0x1a ): undefined reference to `QGArray type_info node'
    /tmp/ccxDBCSi.o: In function `QTextIStream type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf12QTextIStream+0x10 ): undefined reference to `QTextStream type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf12QTextIStream+0x1a ): undefined reference to `QTextStream type_info node'
    /tmp/ccxDBCSi.o: In function `QTextOStream type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf12QTextOStream+0x10 ): undefined reference to `QTextStream type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf12QTextOStream+0x1a ): undefined reference to `QTextStream type_info node'
    /tmp/ccxDBCSi.o: In function `QTimerEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QTimerEvent+0x10) : undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QTimerEvent+0x1a) : undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QMouseEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QMouseEvent+0x10) : undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QMouseEvent+0x1a) : undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QWheelEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QWheelEvent+0x10) : undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QWheelEvent+0x1a) : undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QTabletEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf12QTabletEvent+0x10 ): undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf12QTabletEvent+0x1a ): undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QKeyEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf9QKeyEvent+0x10): undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf9QKeyEvent+0x1a): undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QFocusEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QFocusEvent+0x10) : undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QFocusEvent+0x1a) : undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QPaintEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QPaintEvent+0x10) : undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QPaintEvent+0x1a) : undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QMoveEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf10QMoveEvent+0x10): undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf10QMoveEvent+0x1a): undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QResizeEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf12QResizeEvent+0x10 ): undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf12QResizeEvent+0x1a ): undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QCloseEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QCloseEvent+0x10) : undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QCloseEvent+0x1a) : undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QShowEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf10QShowEvent+0x10): undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf10QShowEvent+0x1a): undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QHideEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf10QHideEvent+0x10): undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf10QHideEvent+0x1a): undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QContextMenuEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf17QContextMenuEvent +0x10): undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf17QContextMenuEvent +0x1a): undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QIMEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf8QIMEvent+0x10): undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf8QIMEvent+0x1a): undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QDragMoveEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf14QDragMoveEvent+0x 10): undefined reference to `QDropEvent type_info function'
    /tmp/ccxDBCSi.o: In function `QDragResponseEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf18QDragResponseEven t+0x10): undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf18QDragResponseEven t+0x1a): undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QDragLeaveEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf15QDragLeaveEvent+0 x10): undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf15QDragLeaveEvent+0 x1a): undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QChildEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QChildEvent+0x10) : undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf11QChildEvent+0x1a) : undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QCustomEvent type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf12QCustomEvent+0x10 ): undefined reference to `QEvent type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf12QCustomEvent+0x1a ): undefined reference to `QEvent type_info node'
    /tmp/ccxDBCSi.o: In function `QSenderObject type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf13QSenderObject+0x1 0): undefined reference to `QObject type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tf13QSenderObject+0x1 a): undefined reference to `QObject type_info node'
    /tmp/ccxDBCSi.o: In function `QAsciiDict<void> type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tft10QAsciiDict1Zv+0x 10): undefined reference to `QGDict type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tft10QAsciiDict1Zv+0x 1a): undefined reference to `QGDict type_info node'
    /tmp/ccxDBCSi.o: In function `QPtrList<void> type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tft8QPtrList1Zv+0x10) : undefined reference to `QGList type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tft8QPtrList1Zv+0x1a) : undefined reference to `QGList type_info node'
    /tmp/ccxDBCSi.o: In function `QPtrList<char> type_info function':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tft8QPtrList1Zc+0x10) : undefined reference to `QGList type_info function'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t.__tft8QPtrList1Zc+0x1a) : undefined reference to `QGList type_info node'
    /tmp/ccxDBCSi.o: In function `QString::~QString(void)':
    /tmp/ccxDBCSi.o(.gnu.linkonce.t._._7QString+0x26): undefined reference to `QString::shared_null'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t._._7QString+0x2e): undefined reference to `QString::shared_null'
    /tmp/ccxDBCSi.o(.gnu.linkonce.t._._7QString+0x3d): undefined reference to `QStringData::deleteSelf(void)'
    collect2: ld returned 1 exit status


    ***********************
    ***********************

    If anyone could give a good explanation on this and how to get round it I would be very thankful.

  2. #2
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    Hi Barrie,

    Fortunately this is not a major setback. You've simply forgotten to include the Qt library in your g++ command line. Try adding '-l qt' as the last argument for g++ and let me know how it goes.
    Jason Deckard

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. QT 4 and MSVC 6.0. Need help/
    By LMZ in forum C++ Programming
    Replies: 1
    Last Post: 09-15-2006, 03:57 PM
  2. QT or others for the beginning linux programmer
    By FillYourBrain in forum Linux Programming
    Replies: 3
    Last Post: 09-12-2003, 01:17 PM
  3. problems with my first attempt at a Qt application...
    By Captain Penguin in forum C++ Programming
    Replies: 0
    Last Post: 10-01-2002, 09:14 PM
  4. First QT App
    By Troll_King in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 07-26-2002, 09:30 AM
  5. Qt
    By Unregistered in forum Linux Programming
    Replies: 2
    Last Post: 01-18-2002, 05:48 AM