Results 1 to 3 of 3

Thread: Qt4->QT5 port, QWidget linker problem, compiles fine (even work in Qt4.8 after ported

  1. #1
    Join Date
    Aug 2008
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt4->QT5 port, QWidget linker problem, compiles fine (even work in Qt4.8 after ported

    I ported my application from QT4.8.2 to QT5.0.1, following the instructions and changed my .pro file added the widgets and printsupport
    TEMPLATE = app
    QT += core gui
    greaterThan(QT_MAJOR_VERSION, 4) {
    QT *= widgets
    QT *= printsupport
    QT += widgets
    }
    FORMS += comms_spy.ui
    CONFIG += qt \
    warn_on
    HEADERS += asc_cntrl.h once_cmd.h comms_spy.h string_defines.h dual_comms.h xmodem.h comms_spy_display.h vt100.h system.h security_def.h \
    ids816.h mea_decode.h mea_decode_ii.h rudp_struct.h cmd_def.h tcp_struct.h script.h atmel_snd1.h

    SOURCES += comms_spy.cpp comms_spy_display.cpp vt100.cpp dual_comms.cpp xmodem.cpp main.cpp mea_decode.cpp mea_decode_ii.cpp script.cpp
    unix {
    TARGET = release/comms_spy
    MOC_DIR = .moc
    OBJECTS_DIR = .obj
    DEFINES += _LINUX_
    }
    RESOURCES += images.qrc
    CONFIG( release) {
    TARGET = comms_spy # debug_binary
    } else {
    TARGET = comms_spy # release_binary
    }
    include (serial_comms/serial_comms.pri)
    include (lib_crc/lib_crc.pri)
    include (gtimer/gtimer.pri)

    CONFIG += debug
    #CONFIG += release

    However it does compile but does not link.. the last few lines are:

    gerrie@quad660:~/workspace/creatron/comms_spy> make
    /home/gerrie/Qt5.0.1/5.0.1/gcc_64/bin/qmake -spec linux-g++-64 CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile comms_spy.pro
    g++ -m64 -Wl,-rpath,/home/gerrie/Qt5.0.1/5.0.1/gcc_64 -Wl,-rpath,/home/gerrie/Qt5.0.1/5.0.1/gcc_64/lib -o comms_spy .obj/comms_spy.o .obj/comms_spy_display.o .obj/vt100.o .obj/dual_comms.o .obj/xmodem.o .obj/main.o .obj/mea_decode.o .obj/mea_decode_ii.o .obj/script.o .obj/serial_comms.o .obj/abstract_serial_comms.o .obj/global_util.o .obj/linux_comms.o .obj/lib_crc.o .obj/gtimer.o .obj/qrc_images.o .obj/moc_comms_spy.o .obj/moc_dual_comms.o .obj/moc_xmodem.o .obj/moc_mea_decode.o .obj/moc_mea_decode_ii.o .obj/moc_script.o -L/usr/X11R6/lib64 -L/home/gerrie/Qt5.0.1/5.0.1/gcc_64/lib -lQt5PrintSupport -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread

    .obj/moc_comms_spy.o.data.rel.ro._ZTV9comms_spy[_ZTV9comms_spy]+0x188): undefined reference to `QWidget::styleChange(QStyle&)'
    .obj/moc_comms_spy.o.data.rel.ro._ZTV9comms_spy[_ZTV9comms_spy]+0x190): undefined reference to `QWidget::enabledChange(bool)'
    .obj/moc_comms_spy.o.data.rel.ro._ZTV9comms_spy[_ZTV9comms_spy]+0x198): undefined reference to `QWidget:aletteChange(QPalette const&)'

    -- more -- very similar

    collect2: error: ld returned 1 exit status
    make: *** [comms_spy] Error 1

    However if I use this project after being ported (remove 'deprecated' ect methods) it still compiles and run under QT4.8.3.

    The QWidget is 'linked' ( -lQt5Widgets ), but I still have unresolved methods.

    Thanks in advance

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt4->QT5 port, QWidget linker problem, compiles fine (even work in Qt4.8 after po

    Do a clean rebuild. That is, ensure that all intermediate files resulting from a Qt4 build are gone.

  3. #3
    Join Date
    Jul 2014
    Posts
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Qt4->QT5 port, QWidget linker problem, compiles fine (even work in Qt4.8 after po

    Hello, I have found a solution for one part of the problem:
    If the object files are created correctly, but the linker fails with this output:

    moc_mainwindow.o:(.data.rel.ro._ZTV10MainWindow[_ZTV10MainWindow]+0x188): undefined reference to `QWidget::styleChange(QStyle&)'
    moc_mainwindow.o:(.data.rel.ro._ZTV10MainWindow[_ZTV10MainWindow]+0x190): undefined reference to `QWidget::enabledChange(bool)'
    moc_mainwindow.o:(.data.rel.ro._ZTV10MainWindow[_ZTV10MainWindow]+0x198): undefined reference to `QWidget::paletteChange(QPalette const&)'
    moc_mainwindow.o:(.data.rel.ro._ZTV10MainWindow[_ZTV10MainWindow]+0x1a0): undefined reference to `QWidget::fontChange(QFont const&)'
    moc_mainwindow.o:(.data.rel.ro._ZTV10MainWindow[_ZTV10MainWindow]+0x1a8): undefined reference to `QWidget::windowActivationChange(bool)'
    moc_mainwindow.o:(.data.rel.ro._ZTV10MainWindow[_ZTV10MainWindow]+0x1b0): undefined reference to `QWidget::languageChange()'

    collect2: error: ld returned 1 exit status

    then you can insert an include directive in one of the header files:

    #include <QWidget>

    and the linker would perform without the errors described above.

    /Wistis

Similar Threads

  1. Replies: 10
    Last Post: 5th April 2011, 04:10
  2. QWidget + QGraphicsView + OenGL view port
    By medved6 in forum Qt Programming
    Replies: 5
    Last Post: 30th March 2011, 07:55
  3. Replies: 1
    Last Post: 16th September 2010, 15:57
  4. problem with ported canvas example
    By bajarangi in forum Newbie
    Replies: 2
    Last Post: 29th July 2009, 22:30
  5. phonon does't work fine in debian/kubuntu/ubuntu
    By skhaz in forum Qt Programming
    Replies: 2
    Last Post: 9th February 2009, 13:01

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.