undefined reference to `vtable for shutdown'
-
@JoeCFD , ok, I've changed the constructor so it is prefixed with explicit and the destructor with virtual which goes back to how it was and I still have the same issue.
-
@SPlatten forget about Qt Creator. Try to build it from command line
Delete build folder
Create build folder
From build folder cmake ${myvariable}
From build folder make VERBOSE=1
add verbose to see more build details. -
@JoeCFD , that is exactly all I am doing. Also cmake is version 2.8.10.2
rm -R build mkdir build cd build cmake ${myvariable} make
In the CMakeLists.txt file I have:
set (CMAKE_VERBOSE_MAKEFILE ON)
-
@JoeCFD , that is exactly all I am doing. Also cmake is version 2.8.10.2
rm -R build mkdir build cd build cmake ${myvariable} make
In the CMakeLists.txt file I have:
set (CMAKE_VERBOSE_MAKEFILE ON)
-
@SPlatten As Jon commented, you can comment the destructor code out and build. It is a small leak. Not a big deal. shutdown is not a good name for class. Try to avoid to use any system command names as your class names. Name it for example ShutdownWindow.
-
@SPlatten As Jon commented, you can comment the destructor code out and build. It is a small leak. Not a big deal. shutdown is not a good name for class. Try to avoid to use any system command names as your class names. Name it for example ShutdownWindow.
-
@SPlatten As Jon commented, you can comment the destructor code out and build. It is a small leak. Not a big deal. shutdown is not a good name for class. Try to avoid to use any system command names as your class names. Name it for example ShutdownWindow.
@JoeCFD , output has changed:
../../(usage.cc.o): In function 'shutdownNotice(char cont*)': vip_system.cc:(.text+0xe1): undefined reference to `vtable for shutdown' vip_system.cc:(.text+0xe9): undefined reference to `vtable for shutdown' vip_system.cc:(.text+0x100): undefined reference to `vtable for shutdown' vip_system.cc:(.text+0x108): undefined reference to `vtable for shutdown' ../../(shutdown.cc.o): In function 'shutdown::shutdown(char cont*, QWidget*)': shutdown.cc:(text+0x3a): undefined reference to `vtable for shutdown' ../../(shutdown.cc.o):shutdown.cc(.text+0x41): more undefined references to `vtable for shutdown' follow collect2 ld returned 1 exit status
-
are you building on Linux, right? If yes, change your class name with ShutdownWindow (do not forget the ui file).
-
are you building on Linux, right? If yes, change your class name with ShutdownWindow (do not forget the ui file).
-
are you building on Linux, right? If yes, change your class name with ShutdownWindow (do not forget the ui file).
-
@JoeCFD , I was hoping this was going to solve the problems, but sadly not, the reports messages are the same just "shutdownWindow" now instead of "shutdown".
-
@SPlatten something weird is going here. This means you can not add any class to your project. You must have other classes. Copy it and change its name to ShutdownWindow. Add it to your project. May I see your
make VERBOSE=1 output?@JoeCFD , could this be a namespace / scope issue? I don't have a lot of experience with namespace and the pitfalls of use.
The C module where these are used are defined in:
namespace a { namespace b { namespace c { static void shutdownNotice(const char* cpszText) { shutdownWindow w(cpszText); w.setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); w.move(QApplication::desktop()->screen()->rect().center() - w.frameGeometry().center()); w.show(); } ...
In the shutdown.h and shutdown.cc files there are no namespaces except in the header:
namespace Ui { class shutdownWindow; }
-
Just for completeness, here is the actual content of the CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8.10) include (flexelint) set (CMAKE_AUTOUIC ON) set (CMAKE_AUTOMOC ON) set (CMAKE_AUTORCC ON) set (CMAKE_INCLUDE_CURRENT_DIR ON) set (FORMS shutdown_ui) set (HEADERS shutdown.h ui_shutdown.h) set (sources shutdown.cc) set (output vip_backend) add_library(${output} STATIC ${sources}) find_package(Qt4 REQUIRED) include(${QT_USE_FILE}) foreach(loop_var ${QT_LIBRARIES}) string(REPLACE lib64 lib32 loop_var ${loop_var}) set(QT_LIBRARIES_32 ${QT_LIBRARIES_32} ${loop_var}) endforeach(loop_var) qt4_wrap_ui(UI_HEADERS ${FORMS}) qt4_wrap_cpp(MOC_SRCS ${HEADERS}) target_link_libraries(${output} ${QT_LIBRARIES_32}) add_flint(${output})
I have no idea what flexelint is or what it does, same is true of add_flint(${output}).
@SPlatten said in undefined reference to `vtable for shutdown':
set (HEADERS shutdown.h
ui_shutdown.h)ui_shutdown.h must not be here. And there must not be such a header file in the source directory!
qt4_wrap_ui(UI_HEADERS ${FORMS})
qt4_wrap_cpp(MOC_SRCS ${HEADERS})This does nothing as long as you don't add the output (UI_HEADERS, MOC_SRCS) to your add_library() call ...
set (FORMS shutdown_ui)
I doubt this is correct.
You have always to have virtual in front of a destructor. Otherwise, you may have unpleasant memory leak in your apps.
This is wrong - the shutdown dtor is virtual by default because QObject's dtor is already virtual
-
I'm now pretty sure the problem is namespace related, but I don't know how to resolve it.
In the source file where the static function shutdownNotice is called it is inside three levels of namespace:
#include "shutdown.h" #include <QApplication> #include <QDesktopWidget> namespace a { namespace b { namespace c { static void shutdownNotice(const char* cpszText) { Ui::shutdownWindow w(cpszText); w.setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); w.move(QApplication::desktop()->screen()->rect().center() - w.frameGeometry().center()); w.show(); } ...
In the header that contains the shutdownWindow class:
shutdown.h:
#ifndef SHUTDOWN_H #define SHUTDOWN_H #include <QMainWindow> namespace Ui { class shutdownWindow; } class shutdownWindow : public QMainWindow { Q_OBJECT public: explicit shutdownWindow(const char* cpszText, QWidget* pParent = 0); ~shutdownWindow(); private: Ui::shutdownWindow* ui; }; #endif // SHUTDOWN_H
#include "shutdown.h" #include "ui_shutdown.h" shutdownWindow::shutdownWindow(const char* cpszText, QWidget* pParent) : QMainWindow(pParent), ui(new Ui::shutdownWindow) { ui->setupUi(this); if ( cpszText ) { ui->plblText->setText(cpszText); } } shutdownWindow::~shutdownWindow() { delete ui; }
With this set-up, the errors are:
In function 'void a::b::c::shutdownNotice(const char*)': error: variable `Ui::shutdownWindow w' has initializer but incomplete type
-
You did not include the required file.
That said, you are using it wrongly. It's not
Ui::shutdownWindow
that you want to instantiate but justshutdownWindow
. -
You did not include the required file.
That said, you are using it wrongly. It's not
Ui::shutdownWindow
that you want to instantiate but justshutdownWindow
.@SGaist , where? what line? because I believe the Ui::shutdownWindow is just used as a forward declaration, also this code was copied from an auto generated header and source file by Qt Creator...create a blank UI class in Qt Creator with a single label, removing the menu and status bar and this is pretty much what you get.
Just to complete the picture the gcc version is Gentoo 4.6.3 p1.13, pie-0.5.2)