Undefined reference to QWidget::styleChange and others
-
Hi every one,
I'm blocked in a project with theses errors:
/usr/bin/ld: moc_Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x188): undefined reference to `QWidget::styleChange(QStyle&)' /usr/bin/ld: moc_Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x190): undefined reference to `QWidget::enabledChange(bool)' /usr/bin/ld: moc_Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x198): undefined reference to `QWidget::paletteChange(QPalette const&)' /usr/bin/ld: moc_Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x1a0): undefined reference to `QWidget::fontChange(QFont const&)' /usr/bin/ld: moc_Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x1a8): undefined reference to `QWidget::windowActivationChange(bool)' /usr/bin/ld: moc_Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x1b0): undefined reference to `QWidget::languageChange()' collect2: error: ld returned 1 exit status
I have already research on internet why I have theses errors but I've found nothing execepted clean, qmake and re-build, but It doesn't work... :(
Window.hpp:
#include <Qt/qgraphicsview.h> #include <Qt/qgraphicsscene.h> class Window : public QGraphicsView { Q_OBJECT public: Window(QGraphicsScene *); ~Window(); };
Window.cpp:
#include "Window.hpp" Window::Window(QGraphicsScene *scene) : QGraphicsView(scene) { setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setFocusPolicy(Qt::NoFocus); setStyleSheet("QGraphicsView {background: 'black';}"); resize(640, 640); show(); } Window::~Window() { } int main() { return 0; }
DEFINES += QT_DEPRECATED_WARNINGS QT += widgets gui core INCLUDEPATH += ./include INCLUDEPATH += ../../core/include HEADERS += include/Window.hpp SOURCES += source/Window.cpp
Thanks in advance.
-
Hi every one,
I'm blocked in a project with theses errors:
/usr/bin/ld: moc_Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x188): undefined reference to `QWidget::styleChange(QStyle&)' /usr/bin/ld: moc_Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x190): undefined reference to `QWidget::enabledChange(bool)' /usr/bin/ld: moc_Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x198): undefined reference to `QWidget::paletteChange(QPalette const&)' /usr/bin/ld: moc_Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x1a0): undefined reference to `QWidget::fontChange(QFont const&)' /usr/bin/ld: moc_Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x1a8): undefined reference to `QWidget::windowActivationChange(bool)' /usr/bin/ld: moc_Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x1b0): undefined reference to `QWidget::languageChange()' collect2: error: ld returned 1 exit status
I have already research on internet why I have theses errors but I've found nothing execepted clean, qmake and re-build, but It doesn't work... :(
Window.hpp:
#include <Qt/qgraphicsview.h> #include <Qt/qgraphicsscene.h> class Window : public QGraphicsView { Q_OBJECT public: Window(QGraphicsScene *); ~Window(); };
Window.cpp:
#include "Window.hpp" Window::Window(QGraphicsScene *scene) : QGraphicsView(scene) { setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setFocusPolicy(Qt::NoFocus); setStyleSheet("QGraphicsView {background: 'black';}"); resize(640, 640); show(); } Window::~Window() { } int main() { return 0; }
DEFINES += QT_DEPRECATED_WARNINGS QT += widgets gui core INCLUDEPATH += ./include INCLUDEPATH += ../../core/include HEADERS += include/Window.hpp SOURCES += source/Window.cpp
Thanks in advance.
-
@jsulm I use Qt 5.11.
I have install it normally ^^ I have already use this version for many other projects.@bozo6919 "normally" can be using Qt Online or Offline installer or your distribution packages.
Are you sure you're using Qt5? Because in Qt5.12 (and I guess Qt5.11) there is no paletteChange for example. But there is such thing in Qt3!
https://doc.qt.io/archives/3.3/qwidget.html#paletteChange -
@bozo6919 "normally" can be using Qt Online or Offline installer or your distribution packages.
Are you sure you're using Qt5? Because in Qt5.12 (and I guess Qt5.11) there is no paletteChange for example. But there is such thing in Qt3!
https://doc.qt.io/archives/3.3/qwidget.html#paletteChange -
@jsulm Yes I'm sure
And I have only Qt 5.11 and Qt 5.12 installed in my computer. I have already seen in another forum that theses functions are from Qt 3, but I don't know why.
-
clean:
14:01:38: Running steps for project qt... 14:01:38: Starting: "/usr/bin/make" clean -j4 rm -f moc_predefs.h rm -f Window.o rm -f *~ core *.core 14:01:38: The process "/usr/bin/make" exited normally. 14:01:38: Elapsed time: 00:00.
qmake:
14:02:18: Running steps for project qt... 14:02:18: Starting: "/home/leo7418/Qt/5.12.0/gcc_64/bin/qmake" /home/leo7418/OOP_arcade_2018/lib/qt/qt.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug 14:02:18: The process "/home/leo7418/Qt/5.12.0/gcc_64/bin/qmake" exited normally. 14:02:18: Starting: "/usr/bin/make" -f /home/leo7418/OOP_arcade_2018/lib/build-qt-Desktop_Qt_5_12_0_GCC_64bit-Debug/Makefile qmake_all make: Nothing to be done for 'qmake_all'. 14:02:18: The process "/usr/bin/make" exited normally. 14:02:18: Elapsed time: 00:00.
compile:
14:02:50: Running steps for project qt... 14:02:50: Configuration unchanged, skipping qmake step. 14:02:50: Starting: "/usr/bin/make" -j4 g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../qt -I. -I../qt/include -I../../core/include -I../../../Qt/5.12.0/gcc_64/include -I../../../Qt/5.12.0/gcc_64/include/QtWidgets -I../../../Qt/5.12.0/gcc_64/include/QtGui -I../../../Qt/5.12.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I../../../Qt/5.12.0/gcc_64/mkspecs/linux-g++ -o Window.o ../qt/source/Window.cpp g++ -Wl,-rpath,/home/leo7418/Qt/5.12.0/gcc_64/lib -o qt Window.o -L/home/leo7418/Qt/5.12.0/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o: in function `_start': (.text+0x24): undefined reference to `main' /usr/bin/ld: Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x188): undefined reference to `QWidget::styleChange(QStyle&)' /usr/bin/ld: Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x190): undefined reference to `QWidget::enabledChange(bool)' /usr/bin/ld: Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x198): undefined reference to `QWidget::paletteChange(QPalette const&)' /usr/bin/ld: Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x1a0): undefined reference to `QWidget::fontChange(QFont const&)' /usr/bin/ld: Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x1a8): undefined reference to `QWidget::windowActivationChange(bool)' /usr/bin/ld: Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x1b0): undefined reference to `QWidget::languageChange()' collect2: error: ld returned 1 exit status make: *** [Makefile:257: qt] Error 1 14:02:51: The process "/usr/bin/make" exited with code 2. Error while building/deploying project qt (kit: Desktop Qt 5.12.0 GCC 64bit) When executing step "Make" 14:02:51: Elapsed time: 00:01.
-
clean:
14:01:38: Running steps for project qt... 14:01:38: Starting: "/usr/bin/make" clean -j4 rm -f moc_predefs.h rm -f Window.o rm -f *~ core *.core 14:01:38: The process "/usr/bin/make" exited normally. 14:01:38: Elapsed time: 00:00.
qmake:
14:02:18: Running steps for project qt... 14:02:18: Starting: "/home/leo7418/Qt/5.12.0/gcc_64/bin/qmake" /home/leo7418/OOP_arcade_2018/lib/qt/qt.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug 14:02:18: The process "/home/leo7418/Qt/5.12.0/gcc_64/bin/qmake" exited normally. 14:02:18: Starting: "/usr/bin/make" -f /home/leo7418/OOP_arcade_2018/lib/build-qt-Desktop_Qt_5_12_0_GCC_64bit-Debug/Makefile qmake_all make: Nothing to be done for 'qmake_all'. 14:02:18: The process "/usr/bin/make" exited normally. 14:02:18: Elapsed time: 00:00.
compile:
14:02:50: Running steps for project qt... 14:02:50: Configuration unchanged, skipping qmake step. 14:02:50: Starting: "/usr/bin/make" -j4 g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../qt -I. -I../qt/include -I../../core/include -I../../../Qt/5.12.0/gcc_64/include -I../../../Qt/5.12.0/gcc_64/include/QtWidgets -I../../../Qt/5.12.0/gcc_64/include/QtGui -I../../../Qt/5.12.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I../../../Qt/5.12.0/gcc_64/mkspecs/linux-g++ -o Window.o ../qt/source/Window.cpp g++ -Wl,-rpath,/home/leo7418/Qt/5.12.0/gcc_64/lib -o qt Window.o -L/home/leo7418/Qt/5.12.0/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o: in function `_start': (.text+0x24): undefined reference to `main' /usr/bin/ld: Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x188): undefined reference to `QWidget::styleChange(QStyle&)' /usr/bin/ld: Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x190): undefined reference to `QWidget::enabledChange(bool)' /usr/bin/ld: Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x198): undefined reference to `QWidget::paletteChange(QPalette const&)' /usr/bin/ld: Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x1a0): undefined reference to `QWidget::fontChange(QFont const&)' /usr/bin/ld: Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x1a8): undefined reference to `QWidget::windowActivationChange(bool)' /usr/bin/ld: Window.o:(.data.rel.ro._ZTV6Window[_ZTV6Window]+0x1b0): undefined reference to `QWidget::languageChange()' collect2: error: ld returned 1 exit status make: *** [Makefile:257: qt] Error 1 14:02:51: The process "/usr/bin/make" exited with code 2. Error while building/deploying project qt (kit: Desktop Qt 5.12.0 GCC 64bit) When executing step "Make" 14:02:51: Elapsed time: 00:01.
@bozo6919 said in Undefined reference to QWidget::styleChange and others:
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o: in function
_start': (.text+0x24): undefined reference to
main'You should fix this issue first: move your main() function in its own file
-
@bozo6919 said in Undefined reference to QWidget::styleChange and others:
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o: in function
_start': (.text+0x24): undefined reference to
main'You should fix this issue first: move your main() function in its own file
-
Hi,
Are you trying to build an old project ?
-
It looks like it. Since it's the moc related code that has issue, I would check what version is run when you try to build your project.