Results 1 to 5 of 5

Thread: Linker problem

  1. #1
    Join Date
    Apr 2010
    Posts
    16
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Linker problem

    Hi All,

    I am new to Qt, got Qt-4.5 commercial version installed on my SUSE 10.0 box

    Now I am doing a feasibility study on compiling qt application by hand and not relying on qmake (its more clumsy and difficult to understand)

    In QT installation, under /examples/widgets directory i am trying to build calculator executable sample

    Step 1 - Compiling
    Compiled the sample using the following compile options
    g++ -c -I/usr/local/Trolltech/Qt-4.5.0/mkspecs/linux-g++-64 -I. -I/usr/local/Trolltech/Qt-4.5.0/include/QtCore -I/usr/local/Trolltech/Qt-4.5.0/include/QtGui -I/usr/local/Trolltech/Qt-4.5.0/include -I. calculator.cpp main.cpp button.cpp

    Step 2 - Linking
    When the object files are linked with Qt libraries I am getting 'undefined references'.
    -linker options:
    g++ -m64 -Wl,-rpath,/usr/local/Trolltech/Qt-4.5.0/lib -o calculator button.o calculator.o main.o -L/usr/local/Trolltech/Qt-4.5.0/lib -lQtGui -lQtCore -L/usr/X11R6/lib64 -pthread -lpthread

    Linker error reported:
    button.o: In function `Button::Button(QString const&, QWidget*)':
    button.cpp: (.text+0x91): undefined reference to `vtable for Button'
    button.cpp: (.text+0x9d): undefined reference to `vtable for Button'
    button.o: In function `Button::Button(QString const&, QWidget*)':
    button.cpp: (.text+0x113): undefined reference to `vtable for Button'
    button.cpp: (.text+0x11f): undefined reference to `vtable for Button'
    calculator.o: In function `Calculator::Calculator(QWidget*)':
    calculator.cpp: (.text+0x141a): undefined reference to `vtable for Calculator'
    calculator.cpp: (.text+0x1429): undefined reference to `vtable for Calculator'
    calculator.o: In function `Calculator::Calculator(QWidget*)':
    calculator.cpp: (.text+0x256e): undefined reference to `vtable for Calculator'
    calculator.cpp: (.text+0x257d): undefined reference to `vtable for Calculator'
    calculator.o: In function `Calculator::tr(char const*, char const*)':
    calculator.cpp: (.text._ZN10Calculator2trEPKcS1_[Calculator::tr(char const*, char const*)]+0x20): undefined reference to `Calculator::staticMetaObject'
    calculator.o: In function `Button* qobject_cast<Button*>(QObject*)':
    calculator.cpp: (.text._Z12qobject_castIP6ButtonET_P7QObject[Button* qobject_cast<Button*>(QObject*)]+0x1f): undefined reference to `Button::staticMetaObject'
    main.o: In function `Calculator::~Calculator()':
    main.cpp: (.text._ZN10CalculatorD1Ev[Calculator::~Calculator()]+0x14): undefined reference to `vtable for Calculator'
    main.cpp: (.text._ZN10CalculatorD1Ev[Calculator::~Calculator()]+0x20): undefined reference to `vtable for Calculator'
    collect2: ld returned 1 exit status


    Can anybody help me ?

    Thanks
    vels

  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: Linker problem

    Quote Originally Posted by vels View Post
    Can anybody help me ?
    Yes, QMake can

    I'd say you forgot to compile and link the file generated by moc (provided you generated it in the first place). That's one of the "clumsyness" and "difficult to understand" things about QMake -- it automates things for you so that you don't have to worry about them. If I were you I would think twice if I really wanted to drop QMake and when I was sure I did, I would think again just to make sure. If I was still convinced that was a good thing to do, I would first learn what QMake did if I wanted to replace it.

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

    vels (8th April 2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    16
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Linker problem

    Thanks for the reply, i will explore qmake

  5. #4
    Join Date
    Apr 2010
    Posts
    16
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Linker problem

    Hi All,

    I got a quick query, is there any way Qmake can be integrated with GNU make? bcz i m planning to use QT as sub system for the main application, where main application will have its own make file and as part of main build Qmake should be performed, since we have moc in Qt is there any better approach to achieve this?

    Thanks
    vels

  6. #5
    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: Linker problem

    QMake uses make to do its job. QMake can also execute any command you wish, make included.

Similar Threads

  1. Linker Lib .a into My VLC project
    By nhs_0702 in forum Qt Programming
    Replies: 1
    Last Post: 13th March 2010, 12:21
  2. please help with linker errors
    By jimboqt in forum Qt Programming
    Replies: 1
    Last Post: 5th July 2007, 09:49
  3. Linker error
    By alfblt16 in forum Qt Programming
    Replies: 2
    Last Post: 28th September 2006, 09:20
  4. Linker Errors
    By MarkoSan in forum Qt Programming
    Replies: 5
    Last Post: 7th March 2006, 18:30
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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.