vels
7th April 2010, 16:16
Hi All,
I am new to Qt, got Qt-4.5 commercial version installed on my SUSE 10.0 box
Now I am doing a feasibility study on compiling qt application by hand and not relying on qmake (its more clumsy and difficult to understand)
In QT installation, under /examples/widgets directory i am trying to build calculator executable sample
Step 1 - Compiling
Compiled the sample using the following compile options
g++ -c -I/usr/local/Trolltech/Qt-4.5.0/mkspecs/linux-g++-64 -I. -I/usr/local/Trolltech/Qt-4.5.0/include/QtCore -I/usr/local/Trolltech/Qt-4.5.0/include/QtGui -I/usr/local/Trolltech/Qt-4.5.0/include -I. calculator.cpp main.cpp button.cpp
Step 2 - Linking
When the object files are linked with Qt libraries I am getting 'undefined references'.
-linker options:
g++ -m64 -Wl,-rpath,/usr/local/Trolltech/Qt-4.5.0/lib -o calculator button.o calculator.o main.o -L/usr/local/Trolltech/Qt-4.5.0/lib -lQtGui -lQtCore -L/usr/X11R6/lib64 -pthread -lpthread
Linker error reported:
button.o: In function `Button::Button(QString const&, QWidget*)':
button.cpp: (.text+0x91): undefined reference to `vtable for Button'
button.cpp: (.text+0x9d): undefined reference to `vtable for Button'
button.o: In function `Button::Button(QString const&, QWidget*)':
button.cpp: (.text+0x113): undefined reference to `vtable for Button'
button.cpp: (.text+0x11f): undefined reference to `vtable for Button'
calculator.o: In function `Calculator::Calculator(QWidget*)':
calculator.cpp: (.text+0x141a): undefined reference to `vtable for Calculator'
calculator.cpp: (.text+0x1429): undefined reference to `vtable for Calculator'
calculator.o: In function `Calculator::Calculator(QWidget*)':
calculator.cpp: (.text+0x256e): undefined reference to `vtable for Calculator'
calculator.cpp: (.text+0x257d): undefined reference to `vtable for Calculator'
calculator.o: In function `Calculator::tr(char const*, char const*)':
calculator.cpp: (.text._ZN10Calculator2trEPKcS1_[Calculator::tr(char const*, char const*)]+0x20): undefined reference to `Calculator::staticMetaObject'
calculator.o: In function `Button* qobject_cast<Button*>(QObject*)':
calculator.cpp: (.text._Z12qobject_castIP6ButtonET_P7QObject[Button* qobject_cast<Button*>(QObject*)]+0x1f): undefined reference to `Button::staticMetaObject'
main.o: In function `Calculator::~Calculator()':
main.cpp: (.text._ZN10CalculatorD1Ev[Calculator::~Calculator()]+0x14): undefined reference to `vtable for Calculator'
main.cpp: (.text._ZN10CalculatorD1Ev[Calculator::~Calculator()]+0x20): undefined reference to `vtable for Calculator'
collect2: ld returned 1 exit status
Can anybody help me ?
Thanks
vels
I am new to Qt, got Qt-4.5 commercial version installed on my SUSE 10.0 box
Now I am doing a feasibility study on compiling qt application by hand and not relying on qmake (its more clumsy and difficult to understand)
In QT installation, under /examples/widgets directory i am trying to build calculator executable sample
Step 1 - Compiling
Compiled the sample using the following compile options
g++ -c -I/usr/local/Trolltech/Qt-4.5.0/mkspecs/linux-g++-64 -I. -I/usr/local/Trolltech/Qt-4.5.0/include/QtCore -I/usr/local/Trolltech/Qt-4.5.0/include/QtGui -I/usr/local/Trolltech/Qt-4.5.0/include -I. calculator.cpp main.cpp button.cpp
Step 2 - Linking
When the object files are linked with Qt libraries I am getting 'undefined references'.
-linker options:
g++ -m64 -Wl,-rpath,/usr/local/Trolltech/Qt-4.5.0/lib -o calculator button.o calculator.o main.o -L/usr/local/Trolltech/Qt-4.5.0/lib -lQtGui -lQtCore -L/usr/X11R6/lib64 -pthread -lpthread
Linker error reported:
button.o: In function `Button::Button(QString const&, QWidget*)':
button.cpp: (.text+0x91): undefined reference to `vtable for Button'
button.cpp: (.text+0x9d): undefined reference to `vtable for Button'
button.o: In function `Button::Button(QString const&, QWidget*)':
button.cpp: (.text+0x113): undefined reference to `vtable for Button'
button.cpp: (.text+0x11f): undefined reference to `vtable for Button'
calculator.o: In function `Calculator::Calculator(QWidget*)':
calculator.cpp: (.text+0x141a): undefined reference to `vtable for Calculator'
calculator.cpp: (.text+0x1429): undefined reference to `vtable for Calculator'
calculator.o: In function `Calculator::Calculator(QWidget*)':
calculator.cpp: (.text+0x256e): undefined reference to `vtable for Calculator'
calculator.cpp: (.text+0x257d): undefined reference to `vtable for Calculator'
calculator.o: In function `Calculator::tr(char const*, char const*)':
calculator.cpp: (.text._ZN10Calculator2trEPKcS1_[Calculator::tr(char const*, char const*)]+0x20): undefined reference to `Calculator::staticMetaObject'
calculator.o: In function `Button* qobject_cast<Button*>(QObject*)':
calculator.cpp: (.text._Z12qobject_castIP6ButtonET_P7QObject[Button* qobject_cast<Button*>(QObject*)]+0x1f): undefined reference to `Button::staticMetaObject'
main.o: In function `Calculator::~Calculator()':
main.cpp: (.text._ZN10CalculatorD1Ev[Calculator::~Calculator()]+0x14): undefined reference to `vtable for Calculator'
main.cpp: (.text._ZN10CalculatorD1Ev[Calculator::~Calculator()]+0x20): undefined reference to `vtable for Calculator'
collect2: ld returned 1 exit status
Can anybody help me ?
Thanks
vels