PDA

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



creatron
27th April 2013, 23:11
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::paletteChange(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

ChrisW67
29th April 2013, 00:28
Do a clean rebuild. That is, ensure that all intermediate files resulting from a Qt4 build are gone.

Wistis
26th July 2014, 17:36
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