Hi, I'm using eclipse integration 1.6.1 and Qt 1.6.2. I'm having a problem creating a simple non-Qt class structure. I've created a folder called "math" and I have these files in it:
DElement.h
/**
* DElement.h
*
* Created on: Feb 27, 2010
* Author: Eric
*
* A generic abstract class for an "element" which can be used in a stack. So it can be a number or an equation.
* Subclasses need to be able to supply a string representation and be able to parse from a string.
*/
#ifndef DELEMENT_H_
#define DELEMENT_H_
#include <QtCore/QString>
class DElement {
public:
virtual void fromString
(const QString &string
) = 0;
DElement();
virtual ~DElement();
};
#endif /* DELEMENT_H_ */
/**
* DElement.h
*
* Created on: Feb 27, 2010
* Author: Eric
*
* A generic abstract class for an "element" which can be used in a stack. So it can be a number or an equation.
* Subclasses need to be able to supply a string representation and be able to parse from a string.
*/
#ifndef DELEMENT_H_
#define DELEMENT_H_
#include <QtCore/QString>
class DElement {
public:
virtual QString toString() = 0;
virtual void fromString(const QString &string) = 0;
DElement();
virtual ~DElement();
};
#endif /* DELEMENT_H_ */
To copy to clipboard, switch view to plain text mode
DElement.cpp
/*
* DElement.cpp
*
* Created on: Feb 27, 2010
* Author: Eric
*/
#include "DElement.h"
DElement::DElement() {
// Not much to do here
}
DElement::~DElement() {
// TODO Auto-generated destructor stub
}
/*
* DElement.cpp
*
* Created on: Feb 27, 2010
* Author: Eric
*/
#include "DElement.h"
DElement::DElement() {
// Not much to do here
}
DElement::~DElement() {
// TODO Auto-generated destructor stub
}
To copy to clipboard, switch view to plain text mode
DNumber.h
/**
* DNumber.h
*
* Created on: Feb 27, 2010
* Author: Eric
*
* DNumber represents a MAPM object which is also a DElement for display purposes.
*/
#ifndef DNUMBER_H_
#define DNUMBER_H_
#include "DElement.h"
// uses MAPM :)
#include <F:/Programs/mapm/M_APM.H>
#include <QtCore/QString>
class DNumber: public DElement, public MAPM {
public:
DNumber(double val);
virtual ~DNumber();
private:
};
#endif /* DNUMBER_H_ */
/**
* DNumber.h
*
* Created on: Feb 27, 2010
* Author: Eric
*
* DNumber represents a MAPM object which is also a DElement for display purposes.
*/
#ifndef DNUMBER_H_
#define DNUMBER_H_
#include "DElement.h"
// uses MAPM :)
#include <F:/Programs/mapm/M_APM.H>
#include <QtCore/QString>
class DNumber: public DElement, public MAPM {
public:
DNumber(double val);
virtual ~DNumber();
private:
};
#endif /* DNUMBER_H_ */
To copy to clipboard, switch view to plain text mode
DNumber.cpp
/*
* DNumber.cpp
*
* Created on: Feb 27, 2010
* Author: Eric
*/
#include "DNumber.h"
DNumber::DNumber(double val) {
// TODO Auto-generated constructor stub
}
DNumber::~DNumber() {
// TODO Auto-generated destructor stub
}
/*
* DNumber.cpp
*
* Created on: Feb 27, 2010
* Author: Eric
*/
#include "DNumber.h"
DNumber::DNumber(double val) {
// TODO Auto-generated constructor stub
}
DNumber::~DNumber() {
// TODO Auto-generated destructor stub
}
To copy to clipboard, switch view to plain text mode
And the following error is produced:
mingw32-make debug
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `G:/Documents/Projects/Demurr'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"f:\Programs\Qt4.6\qt\include\QtCore" -I"f:\Programs\Qt4.6\qt\include\QtGui" -I"f:\Programs\Qt4.6\qt\include\QtOpenGL" -I"f:\Programs\Qt4.6\qt\include" -I"f:\Programs\Qt4.6\qt\include\ActiveQt" -I"debug" -I"." -I"f:\Programs\Qt4.6\qt\mkspecs\win32-g++" -o debug\DNumber.o math\DNumber.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\Demurr.exe debug/DNumber.o debug/main.o debug/mainwindow.o debug/stacktabwidget.o debug/tabpage.o debug/stacktablemodel.o debug/moc_mainwindow.o debug/moc_stacktabwidget.o debug/moc_tabpage.o -L"f:\Programs\Qt4.6\qt\lib" -lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmaind -lQtOpenGLd4 -lQtGuid4 -lQtCored4
debug/DNumber.o: In function `DNumber':
G:\Documents\Projects\Demurr/math/DNumber.cpp:10: undefined reference to `DElement::DElement()'
G:\Documents\Projects\Demurr/math/DNumber.cpp:13: undefined reference to `DElement::~DElement()'
G:\Documents\Projects\Demurr/math/DNumber.cpp:10: undefined reference to `DElement::DElement()'
G:\Documents\Projects\Demurr/math/DNumber.cpp:13: undefined reference to `DElement::~DElement()'
debug/DNumber.o: In function `~DNumber':
G:\Documents\Projects\Demurr/math/DNumber.cpp:17: undefined reference to `DElement::~DElement()'
G:\Documents\Projects\Demurr/math/DNumber.cpp:17: undefined reference to `DElement::~DElement()'
G:\Documents\Projects\Demurr/math/DNumber.cpp:17: undefined reference to `DElement::~DElement()'
G:\Documents\Projects\Demurr/math/DNumber.cpp:17: undefined reference to `DElement::~DElement()'
debug/DNumber.o:G:\Documents\Projects\Demurr/math/DNumber.cpp:17: more undefined references to `DElement::~DElement()' follow
mingw32-make debug
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `G:/Documents/Projects/Demurr'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"f:\Programs\Qt4.6\qt\include\QtCore" -I"f:\Programs\Qt4.6\qt\include\QtGui" -I"f:\Programs\Qt4.6\qt\include\QtOpenGL" -I"f:\Programs\Qt4.6\qt\include" -I"f:\Programs\Qt4.6\qt\include\ActiveQt" -I"debug" -I"." -I"f:\Programs\Qt4.6\qt\mkspecs\win32-g++" -o debug\DNumber.o math\DNumber.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\Demurr.exe debug/DNumber.o debug/main.o debug/mainwindow.o debug/stacktabwidget.o debug/tabpage.o debug/stacktablemodel.o debug/moc_mainwindow.o debug/moc_stacktabwidget.o debug/moc_tabpage.o -L"f:\Programs\Qt4.6\qt\lib" -lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmaind -lQtOpenGLd4 -lQtGuid4 -lQtCored4
debug/DNumber.o: In function `DNumber':
G:\Documents\Projects\Demurr/math/DNumber.cpp:10: undefined reference to `DElement::DElement()'
G:\Documents\Projects\Demurr/math/DNumber.cpp:13: undefined reference to `DElement::~DElement()'
G:\Documents\Projects\Demurr/math/DNumber.cpp:10: undefined reference to `DElement::DElement()'
G:\Documents\Projects\Demurr/math/DNumber.cpp:13: undefined reference to `DElement::~DElement()'
debug/DNumber.o: In function `~DNumber':
G:\Documents\Projects\Demurr/math/DNumber.cpp:17: undefined reference to `DElement::~DElement()'
G:\Documents\Projects\Demurr/math/DNumber.cpp:17: undefined reference to `DElement::~DElement()'
G:\Documents\Projects\Demurr/math/DNumber.cpp:17: undefined reference to `DElement::~DElement()'
G:\Documents\Projects\Demurr/math/DNumber.cpp:17: undefined reference to `DElement::~DElement()'
debug/DNumber.o:G:\Documents\Projects\Demurr/math/DNumber.cpp:17: more undefined references to `DElement::~DElement()' follow
To copy to clipboard, switch view to plain text mode
Which is stupid because
class A
{
public:
A();
virtual ~A();
};
class B : public A
{
public:
B();
virtual ~B();
};
A::A(){}
A::~A(){}
B::B(){}
B::~B(){}
class A
{
public:
A();
virtual ~A();
};
class B : public A
{
public:
B();
virtual ~B();
};
A::A(){}
A::~A(){}
B::B(){}
B::~B(){}
To copy to clipboard, switch view to plain text mode
this compiles fine, even if I split it into separate files. It's not the pure virtuals either, I got rid of = 0 and it still fails. I wish I could spend more time developing and less time trying to fix strange errors that should not be happening. I've been trying to use Qt for some projects of mine for over a year and I finally got a project to compile only yesterday. MAPM is creating more errors but I'd like to clear up this first.
Bookmarks