PDA

View Full Version : Error : undefined reference to `vtable for MyClass'



joseph
13th June 2007, 12:15
hi guys,

While compiling at the time of linking , am getting the error : undefined reference to `vtable for ChemHeaderFooterOptions'




see .pro file


TEMPLATE = app
LANGUAGE = C++

CONFIG += qt warn_on debug

unix:LIBS += -lXext -lm

DEFINES += SYNSUP_GUI

QT += qt3support

INCLUDEPATH += . ./common
unix:MOC_DIR += ../source/linuxmoc
unix:OBJECTS_DIR += ../source/linuxobj
win32:MOC_DIR += ../source/Winmoc
win32:OBJECTS_DIR += ../source/Winobj
unix:UI_HEADERS_DIR = ../source/dlg
win32:UI_HEADERS_DIR = ../source/dlg
unix:UI_SOURCES_DIR = ../source/dlg
win32:UI_SOURCES_DIR = ../source/dlg

HEADERS += atomgroup.h \
atomicnumber.h \
canonlist.h \
chemcanvas.h \
chemedit.h \
chemenums.h \
chemglobals.h \
chemicons.h \
chemmap.h \
chemobj.h \
chemstate.h \
chemstructs.h \
chemtree.h \
chemtreecanvas.h \
chemutils.h \
common/atomarray.h \
common/rownumberarray.h \
common/alist.h \
common/atom.h \
common/atominring.h \
common/atompair.h \
common/availmol.h \
common/basefragment.h \
common/basemolecule.h \
common/commondec.h \
common/fglist.h \
common/integerlist.h \
common/nbrlist.h \
common/ring.h \
common/ringpair.h \
common/synsupmatrix.h \
common/synsupvector.h \
common/twoatomsinring.h \
common/utils.h \
coord.h \
ct.h \
datom.h \
dbond.h \
dgroup.h \
dlg/AtomPropertiesDlg.h \
dlg/BondPropertiesDlg.h \
dlg/BondPropertiesDlgData.h \
dlg/CmbeditInfo.h \
dlg/CanvasPaperDlg.h \
dlg/Functionalgrouplimitdlg.h \
dlg/HeaderFooterInfoDlg.h \
dlg/MySpinBox.h \
dlg/PageSetupDlg.h \
dlg/ServerPreferences.h \
dlg/SynsupMail.h \
dlg/SynsupOptionsDlg.h \
dlg/SynsupOptionsDlgData.h \
dlg/SynViewerPropertyDlg.h \
dlg/ViewPreferences.h \
dmolecule.h \
dreaction.h \
dring.h \
droute.h \
dsymbol.h \
dtext.h \
elemchooser.h \
fontchooser.h \
headerAndFooterFormatter.h \
headerFooterOptions.h \
mappings.h \
molproperty.h \
route.h \
scrollchemcanvas.h \
smtp.h \
showToolTip.h \
synViewerproperty.h \
synsupoptions.h \
templatechooser.h \
wcpoint.h \
zoomer.h

SOURCES += atomgroup.cpp \
chemcanvas.cpp \
chemedit.cpp \
chemglobals.cpp \
chemicons.cpp \
chemmap.cpp \
chemobj.cpp \
chemstate.cpp \
chemtree.cpp \
chemtreecanvas.cpp \
chemutils.cpp \
common/rownumberarray.cpp \
common/alist.cpp \
common/atom.cpp \
common/atominring.cpp \
common/atompair.cpp \
common/basefragment.cpp \
common/basemolecule.cpp \
common/basestereo.cpp \
common/canon.cpp \
common/fglist.cpp \
common/integerlist.cpp \
common/nbrlist.cpp \
common/ring.cpp \
common/ringpair.cpp \
common/rings.cpp \
common/twoatomsinring.cpp \
common/utils.cpp \
coord.cpp \
ct.cpp \
datom.cpp \
dbond.cpp \
dgroup.cpp \
dlg/AtomPropertiesDlg.cpp \
dlg/BondPropertiesDlg.cpp \
dlg/BondPropertiesDlgData.cpp \
dlg/CmbeditInfo.cpp \
dlg/CanvasPaperDlg.cpp \
dlg/Functionalgrouplimitdlg.cpp \
dlg/HeaderFooterInfoDlg.cpp \
dlg/MySpinBox.cpp\
dlg/PageSetupDlg.cpp \
dlg/ServerPreferences.cpp \
dlg/SynsupMail.cpp \
dlg/SynsupOptionsDlg.cpp \
dlg/SynsupOptionsDlgData.cpp \
dlg/SynViewerPropertyDlg.cpp \
dlg/ViewPreferences.cpp \
dmolecule.cpp \
dreaction.cpp \
dring.cpp \
droute.cpp \
dsymbol.cpp \
dtext.cpp \
elemchooser.cpp \
fontchooser.cpp \
headerAndFooterFormatter.cpp \
headerFooterOptions.cpp \
main.cpp \
mappings.cpp \
molproperty.cpp \
ncoord.cpp \
route.cpp \
scrollchemcanvas.cpp \
synViewerproperty.cpp \
smtp.cpp \
ShowToolTip.cpp \
synsupoptions.cpp \
templatechooser.cpp \
zoomer.cpp

FORMS += dlg/SynsupMailDlg.ui \
dlg/Functionalgrouplimitdlg.ui \
dlg/PageSetupDlg.ui \
dlg/ServerPreferencesDlg.ui \
dlg/AtomPropertiesDlgData.ui \
dlg/SynsupOptionsDlgData.ui \
dlg/SynViewerPropertyDlg.ui \
dlg/HeaderFooterInfoDlg.ui \
dlg/ViewPreferencesDlg.ui \
dlg/InfoDlg.ui \



win32:TMAKE_CFLAGS = -TP
win32:TMAKE_CXXFLAGS = -GX
win32:RC_FILE = chemedit.rc
CONFIG += non_threaded
TARGET = cmbedit
TRANSLATIONS = chemedit_en.ts \
chemedit_jp.ts
#The following line was inserted by qt3to4
QT +=




See .h file



#ifndef _ChemHeaderFooterOptions_

#define _ChemHeaderFooterOptions_



#include <q3hbox.h>

#include <q3popupmenu.h>

#include <qpushbutton.h>

#include <q3mainwindow.h>

#include <qstring.h>

#include <qtoolbutton.h>

#include <q3toolbar.h>

#include <qtooltip.h>

#include "chemtree.h"

#include "headerAndFooterFormatter.h"


class ChemHeaderFooterOptions:public Q3ToolBar

{

Q_OBJECT

public:
// Constructor
ChemHeaderFooterOptions(ChemTree::SynViewMode synViewMode, Q3MainWindow *parent = 0, char *name = "",

ChemCanvas *canvas = 0 );



public slots:
void closeFormater();

protected slots:

private:

};
#endif



See the .cpp file below



//constructor. Here is the error [ undefined refernce to vtable ...] points ,

ChemHeaderFooterOptions::ChemHeaderFooterOptions(C hemTree::SynViewMode synViewMode, Q3MainWindow *parent, char *name, ChemCanvas *canvas)
:Q3ToolBar(parent, name)

{
// some normal coding
}


See the Error : that i have received while linking


/root/Desktop/June12porting_to_Qt4/source/headerFooterOptions.cpp:26: undefined reference to `vtable for ChemHeaderFooterOptions'
../source/linuxobj/headerFooterOptions.o(.text+0xba):/root/Desktop/June12porting_to_Qt4/source/headerFooterOptions.cpp:26: undefined reference to `vtable for ChemHeaderFooterOptions'
/root/Desktop/June12porting_to_Qt4/source/headerFooterOptions.cpp:26: undefined reference to `vtable for ChemHeaderFooterOptions'
../source/linuxobj/headerFooterOptions.o(.text+0x18dc):/root/Desktop/June12porting_to_Qt4/source/headerFooterOptions.cpp:26: undefined reference to `vtable for ChemHeaderFooterOptions'
*** Exited with status: 2 ***




What i did so far :--

1) . I included the files in .pro files properly
2). cleared the .obj && moc files.
3) then rebuild the porject


After all my attempts i am getting the same error.
Please help me.
Thanks

jpn
13th June 2007, 12:20
What i did so far :--

1) . I included the files in .pro files properly
2). cleared the .obj && moc files.
3) then rebuild the porject
Try also re-running qmake.

high_flyer
13th June 2007, 12:28
can you show the full compile output?
It looks like moc is not being run.

joseph
13th June 2007, 13:25
can you show the full compile output?
It looks like moc is not being run.


See i have used "Q_OBJECT" macro in so amny files , there is no moc problem am getting. Only in this "headerFooterOptions.cpp" i am getting this error.


If mocing is done properly how the other files will work.
Anyother hint. ..??
please help me

joseph
13th June 2007, 13:26
Try also re-running qmake.

i have tried this also. Still getting the same error.
Anyother way..??
pleaseee..

high_flyer
13th June 2007, 13:33
See i have used "Q_OBJECT" macro in so amny files , there is no moc problem am getting.
The only way to be sure is to see the compile output.

joseph
13th June 2007, 13:45
The only way to be sure is to see the compile output.


see this is the compilation results....


cd '/root/Desktop/Feb_June12Porting_to_Qt4/source' && QTDIR="/usr/lib/qt-3.3" gmake -j1 clean && QTDIR="/usr/lib/qt-3.3" gmake -j1

generating ../source/linuxmoc/moc_HeaderFooterInfoDlg.cpp (moc)
compiling moc_HeaderFooterInfoDlg.cpp (g++)

generating ../source/linuxmoc/moc_dsymbol.cpp (moc)
compiling moc_dsymbol.cpp (g++)

linking cmbedit (g++)
/root/Desktop/Feb_June12Porting_to_Qt4/source/headerFooterOptions.cpp:26: undefined reference to `vtable for ChemHeaderFooterOptions'
../source/linuxobj/headerFooterOptions.o(.text+0xba):/root/Desktop/Feb_June12Porting_to_Qt4/source/headerFooterOptions.cpp:26: undefined reference to `vtable for ChemHeaderFooterOptions'
/root/Desktop/Feb_June12Porting_to_Qt4/source/headerFooterOptions.cpp:26: undefined reference to `vtable for ChemHeaderFooterOptions'
../source/linuxobj/headerFooterOptions.o(.text+0x18dc):/root/Desktop/Feb_June12Porting_to_Qt4/source/headerFooterOptions.cpp:26: undefined reference to `vtable for ChemHeaderFooterOptions'
*** Exited with status: 2 ***




working environment :-

1) kde 3.2
2) fedora 4
3 ) i am poritng the application from Qt3.3.4 to Qt4.2.2


thank you

high_flyer
13th June 2007, 14:12
hmm... are you sure you are using the correct qmake? (Qt4 and not Qt3)
If you can, allow a full compile command output then we can see exactly what is being called.

P.S
It is REALLY not recommended to work as root!
P.P.S

3 ) i am poritng the application from Qt3.3.4 to Qt4.2.2
I assume that by porting, you are not just compiling it with Qt4 - and that you changed the code to Qt4.

Looking at the headers you are using, you are only using Qt3 headers, and Qt3 support headers from Qt4... this doesn't look correct.

jpn
13th June 2007, 14:53
What does "qmake -v" output?

joseph
13th June 2007, 14:55
I assume that by porting, you are not just compiling it with Qt4 - and that you changed the code to Qt4.

Looking at the headers you are using, you are only using Qt3 headers, and Qt3 support headers from Qt4... this doesn't look correct.


yaa , we are in the first phase of porting.
phase 1: In this phase we will port it using the Qt3 support module
phase 2: if i successfully completed the first phase, then i will remove the Qt3 support, and will use the pure qt4 classes. ( this is asper the porting doc in assistant )

high_flyer
13th June 2007, 15:09
you still didn't answer the above questions....


if i successfully completed the first phase, then i will remove the Qt3 support, and will use the pure qt4 classes. ( this is asper the porting doc in assistant )
Yes, but from your code, it looks like you are using the Qt3 support classes of Qt4 , but still using the old Qt3 headers in parallel.
If this is the case, no woder you have trouble.
You should use the Qt4's Qt3-support in a Qt4 project, and code, meaning, the headers need to be Qt4 headers, and linking also against Qt4.
It looks to me you are only linking against Qt4, use Qt4's Qt3-Support headers, and the old Qt3 headers - this wont wrok.

croland
13th June 2007, 15:42
Can you post headerFooterOptions.h and headerFooterOptions.cpp?

joseph
13th June 2007, 16:02
Can you post headerFooterOptions.h and headerFooterOptions.cpp?


please refer the begining of this thread...

jpn
13th June 2007, 16:14
And what about "qmake -v" output?

croland
13th June 2007, 17:03
If I'm barking up the wrong tree let me know.

Did or do you need to include "chemcanvas.h"?

joseph
15th June 2007, 08:09
And what about "qmake -v" output?

The output after using "qmake -v "


QMake version 2.01a
Using Qt version 4.2.3 in /usr/local/Trolltech/Qt-4.2.3/lib


While compiling my program I am getting the below warning....

headerFooterOptions.h:0: Warning: No relevant classes found. No output generated.


And the linker error occured....



generating ../source/linuxmoc/moc_headerFooterOptions.cpp (moc)
compiling moc_headerFooterOptions.cpp (g++)
headerFooterOptions.h:0: Warning: No relevant classes found. No output generated.
linking MyProject (g++)
/root/Desktop/headerFooterOptions.cpp:22: undefined reference to `vtable for HeaderFooterOptions'
../source/linuxobj/source/headerFooterOptions.o(.text+0xba):/root/Desktop/source/headerFooterOptions.cpp:22: undefined reference to `vtable for HeaderFooterOptions'
/root/Desktop/source/headerFooterOptions.cpp:22:undefined reference to `vtable for HeaderFooterOptions'
../source/linuxobj/headerFooterOptions.o(.text+0x1904):/root/Desktop/source/headerFooterOptions.cpp:22: undefined reference to `vtable for HeaderFooterOptions'
*** Exited with status: 2 ***


thanks.....

high_flyer
15th June 2007, 10:13
but you didn't respond to this:

Yes, but from your code, it looks like you are using the Qt3 support classes of Qt4 , but still using the old Qt3 headers in parallel.
If this is the case, no woder you have trouble.
You should use the Qt4's Qt3-support in a Qt4 project, and code, meaning, the headers need to be Qt4 headers, and linking also against Qt4.
It looks to me you are only linking against Qt4, use Qt4's Qt3-Support headers, and the old Qt3 headers - this wont wrok.
If what I wrote here is correct, your problem is mixing Qt3 and Qt4 - at least.
You might have also a problem with the tool chain, but you first need to use the correct libs with the correct code.

jpn
15th June 2007, 10:24
It looks to me you are only linking against Qt4, use Qt4's Qt3-Support headers, and the old Qt3 headers - this wont wrok.
Actually the convenience headers like "QToolButton" are there only for convenience. They do nothing but include the corresponding actual header like "qtoolbutton.h". So the old Qt3'ish headers still exist and using them is not a problem. They are used all over Qt itself too.

high_flyer
15th June 2007, 10:29
ok, what I had in mind is that he is including them from /lib/qt3/inlclude.
But if he is using the right qmake, and didn't change inlcude path explicitly, this should not be a problem, you are correct.

high_flyer
15th June 2007, 10:31
headerFooterOptions.h:0: Warning: No relevant classes found. No output generated.
and

#ifndef _ChemHeaderFooterOptions_
what is the headerFooterOptions file name?
ChemHeaderFooterOptions.h or headerFooterOptions.h?
EDIT:
Naaa... forget it, it should have given a "file not found" error...

joseph
15th June 2007, 10:58
what is the headerFooterOptions file name?
ChemHeaderFooterOptions.h or headerFooterOptions.h?


ChemHeaderFooterOptions is a class inside headerFooterOptions.h

jpn
15th June 2007, 11:03
headerFooterOptions.h:0: Warning: No relevant classes found. No output generated.


I can't spot the reason, but for some reason moc does not like the class declaration in headerFooterOptions.h. The only fault I can spot is an extra "\" at the end of FORMS variable in the .pro file.

high_flyer
15th June 2007, 11:40
joseph: what happens if you run manually moc on headerFooterOptions.h?
Does it create a moc then, or does the error repeat ti self?

croland
15th June 2007, 12:21
Hey Joseph,

You have ChemCanvas in your constructor, do you need to include chemcanvas.h?