Hi
I've been trying to get my head around a linking error for a couple of days now. I have a library which has a QMainWindow derived class. The library builds fine, but when I create an instance of the derived class in a simple example program, the linker fails with the error below. I know what this error means, but I don't see how it applies to my situation:
../../tmp/actionmanagementexample/main.o: In function `Z5qMainiPPc':
d:\ScinericSoftware\Products\Qtilities\trunk\libraries\ObjManagementLib\examples\ActionManagement/main.cpp:31: undefined reference to `Qtilities::ObjManagement::ExtendedMainWindow::ExtendedMainWindow(QWidget*)'
../../tmp/actionmanagementexample/main.o: In function `Z5qMainiPPc':
d:\ScinericSoftware\Products\Qtilities\trunk\libraries\ObjManagementLib\examples\ActionManagement/main.cpp:31: undefined reference to `Qtilities::ObjManagement::ExtendedMainWindow::ExtendedMainWindow(QWidget*)'
To copy to clipboard, switch view to plain text mode
Here is my main program:
#include <QtGui>
#include <ExtendedMainWindow.h>
using namespace Qtilities::ObjManagement;
int main(int argc, char *argv[])
{
ExtendedMainWindow* mainWindow = new ExtendedMainWindow(0);
mainWindow->show();
return a.exec();
}
#include <QtGui>
#include <ExtendedMainWindow.h>
using namespace Qtilities::ObjManagement;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ExtendedMainWindow* mainWindow = new ExtendedMainWindow(0);
mainWindow->show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
and my .pro file:
TARGET = ActionManagement
TEMPLATE = app
SOURCES += main.cpp
LIBS += ../../bin/libObjManagementLib.a
CONFIG += debug
TARGET = ActionManagement
TEMPLATE = app
SOURCES += main.cpp
LIBS += ../../bin/libObjManagementLib.a
CONFIG += debug
To copy to clipboard, switch view to plain text mode
And the ExtendedMainWindow class:
#ifndef OBJMANGEMENTLIBMAINWINDOW_H
#define OBJMANGEMENTLIBMAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class ExtendedMainWindow;
}
namespace Qtilities {
namespace ObjManagement {
struct ExtendedMainWindowData;
Q_OBJECT
public:
ExtendedMainWindow
(QWidget *parent
= 0);
~ExtendedMainWindow();
protected:
private:
Ui::ExtendedMainWindow *ui;
ExtendedMainWindowData* d;
};
}
}
#endif // OBJMANGEMENTLIBMAINWINDOW_H
#ifndef OBJMANGEMENTLIBMAINWINDOW_H
#define OBJMANGEMENTLIBMAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class ExtendedMainWindow;
}
namespace Qtilities {
namespace ObjManagement {
struct ExtendedMainWindowData;
class ExtendedMainWindow : public QMainWindow {
Q_OBJECT
public:
ExtendedMainWindow(QWidget *parent = 0);
~ExtendedMainWindow();
protected:
void changeEvent(QEvent *e);
private:
Ui::ExtendedMainWindow *ui;
ExtendedMainWindowData* d;
};
}
}
#endif // OBJMANGEMENTLIBMAINWINDOW_H
To copy to clipboard, switch view to plain text mode
And the .cpp implementation of ExtendedMainWindow:
#include "ExtendedMainWindow.h"
#include "ui_ExtendedMainWindow.h"
struct Qtilities::ObjManagement::ExtendedMainWindowData {
ExtendedMainWindowData() { }
};
Qtilities
::ObjManagement::ExtendedMainWindow::ExtendedMainWindow(QWidget *parent
) : ui(new Ui::ExtendedMainWindow)
{
ui->setupUi(this);
d = new ExtendedMainWindowData;
}
Qtilities::ObjManagement::ExtendedMainWindow::~ExtendedMainWindow()
{
delete ui;
delete d;
}
void Qtilities
::ObjManagement::ExtendedMainWindow::changeEvent(QEvent *e
) {
switch (e->type()) {
ui->retranslateUi(this);
break;
default:
break;
}
}
#include "ExtendedMainWindow.h"
#include "ui_ExtendedMainWindow.h"
struct Qtilities::ObjManagement::ExtendedMainWindowData {
ExtendedMainWindowData() { }
};
Qtilities::ObjManagement::ExtendedMainWindow::ExtendedMainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ExtendedMainWindow)
{
ui->setupUi(this);
d = new ExtendedMainWindowData;
}
Qtilities::ObjManagement::ExtendedMainWindow::~ExtendedMainWindow()
{
delete ui;
delete d;
}
void Qtilities::ObjManagement::ExtendedMainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
To copy to clipboard, switch view to plain text mode
The UI file is just a plain QMainWindow with nothing on it, called ExtendedMainWindow. I don't understand how the library is able to build (which means that it find the implementation of those functions), but linking against it does not work. Creating wit
Any ideas will be greatly appreciated.
Thanks,
Jaco
Bookmarks