View previous topic :: View next topic |
Author |
Message |
josko Tux's lil' helper
Joined: 02 Mar 2007 Posts: 91
|
Posted: Thu Apr 26, 2007 6:58 pm Post subject: Kdevelop installation: errors? |
|
|
Strange...
This simple code, from tutorial t1, gives errors back?
Quote: | #include <QtGui/QApplication>
#include <QtGui/QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello world!");
hello.resize(100, 30);
hello.show();
return app.exec();
} |
The errors:
Quote: | cd '/root/Qt4/imageLoader' && gmake -k
cd src && gmake -f Makefile
compiling main.cpp (g++)
main.cpp:13:3: warning: no newline at end of file
linking ../bin/imageloader (g++)
main.o: In function `main':
main.cpp:(.text+0x25): undefined reference to `QApplication::QApplication(int&, char**, int)'
main.cpp:(.text+0x4d): undefined reference to `QPushButton::QPushButton(QString const&, QWidget*)'
main.cpp:(.text+0x83): undefined reference to `QWidget::resize(QSize const&)'
main.cpp:(.text+0x98): undefined reference to `QApplication::exec()'
main.cpp:(.text+0xa2): undefined reference to `QPushButton::~QPushButton()'
main.cpp:(.text+0xaa): undefined reference to `QApplication::~QApplication()'
main.cpp:(.text+0xc0): undefined reference to `QApplication::~QApplication()'
main.cpp:(.text+0xd3): undefined reference to `QPushButton::~QPushButton()'
collect2: ld returned 1 exit status
gmake[1]: *** [../bin/imageloader] Error 1
gmake[1]: Target `first' not remade because of errors.
gmake: *** [sub-src-make_default] Error 2
gmake: Target `first' not remade because of errors.
*** Exited with status: 2 ***
|
I get the same type of errors with tutorial-5
And i *think* the config is good;
http://img46.imageshack.us/img46/7863/snapshot11yq3.png
Any ideas? |
|
Back to top |
|
|
josko Tux's lil' helper
Joined: 02 Mar 2007 Posts: 91
|
Posted: Fri Apr 27, 2007 3:20 pm Post subject: |
|
|
nobody? |
|
Back to top |
|
|
jawilson n00b
Joined: 03 Apr 2004 Posts: 64 Location: Madison, WI, USA
|
Posted: Fri Apr 27, 2007 8:50 pm Post subject: |
|
|
What happens if you run it from the command line? Also, I would try taking the QtGui/ out of the #include statements; I have never included it, and Qt apps compile fine for me.
I just did this:
Code: | #include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello world!");
hello.resize(100, 30);
hello.show();
return app.exec();
}
|
and it compiles and runs fine from the command line. Not sure about kdevelop...
(EDIT)
Yep, it works in kdevelop. This is probably a dumb question, but you're sure you have qt4 installed, and not just qt3? (Just want to make sure ) |
|
Back to top |
|
|
josko Tux's lil' helper
Joined: 02 Mar 2007 Posts: 91
|
Posted: Sat Apr 28, 2007 11:35 am Post subject: |
|
|
Yup, got qt4 installed. (That's where the last topic was all about)
lets see... The QtGui/ is there, cause else i get ' QApplication is not defined' or something like that.
Kdevelop:
Without QtGui/:
Code: | cd '/root/Qt4/imageLoader' && gmake -k
cd src && gmake -f Makefile
compiling main.cpp (g++)
main.cpp:1:25: error: QApplication: No such file or directory
main.cpp:2:24: error: QPushButton: No such file or directory
main.cpp:13:3: warning: no newline at end of file
main.cpp: In function 'int main(int, char**)':
main.cpp:6: error: 'QApplication' was not declared in this scope
main.cpp:6: error: expected `;' before 'app'
main.cpp:8: error: 'QPushButton' was not declared in this scope
main.cpp:8: error: expected `;' before 'hello'
main.cpp:9: error: 'hello' was not declared in this scope
main.cpp:12: error: 'app' was not declared in this scope
main.cpp: At global scope:
main.cpp:4: warning: unused parameter 'argc'
main.cpp:4: warning: unused parameter 'argv'
gmake[1]: *** [main.o] Error 1
gmake[1]: Target `first' not remade because of errors.
gmake: *** [sub-src-make_default] Error 2
gmake: Target `first' not remade because of errors.
*** Exited with status: 2 ***
|
with:
Code: | gmake[1]: Target `first' not remade because of errors.
|
command line:
without:
Tranquality imageLoader # qmake
Tranquality imageLoader # make
Code: | cd src && make -f Makefile
make[1]: Entering directory `/root/Qt4/imageLoader/src'
g++ -c -pipe -O2 -pipe -D_REENTRANT -Wall -W -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -I. -o main.o main.cpp
main.cpp:1:25: error: QApplication: No such file or directory
main.cpp:2:24: error: QPushButton: No such file or directory
main.cpp:13:3: warning: no newline at end of file
main.cpp: In function 'int main(int, char**)':
main.cpp:6: error: 'QApplication' was not declared in this scope
main.cpp:6: error: expected `;' before 'app'
main.cpp:8: error: 'QPushButton' was not declared in this scope
main.cpp:8: error: expected `;' before 'hello'
main.cpp:9: error: 'hello' was not declared in this scope
main.cpp:12: error: 'app' was not declared in this scope
main.cpp: At global scope:
main.cpp:4: warning: unused parameter 'argc'
main.cpp:4: warning: unused parameter 'argv'
make[1]: *** [main.o] Error 1
make[1]: Leaving directory `/root/Qt4/imageLoader/src'
make: *** [sub-src-make_default] Error 2
|
with:
Code: | Tranquality imageLoader # make
cd src && make -f Makefile
make[1]: Entering directory `/root/Qt4/imageLoader/src'
g++ -c -pipe -O2 -pipe -D_REENTRANT -Wall -W -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -I. -o main.o main.cpp
main.cpp:1:25: error: QApplication: No such file or directory
main.cpp:2:24: error: QPushButton: No such file or directory
main.cpp:13:3: warning: no newline at end of file
main.cpp: In function 'int main(int, char**)':
main.cpp:6: error: 'QApplication' was not declared in this scope
main.cpp:6: error: expected `;' before 'app'
main.cpp:8: error: 'QPushButton' was not declared in this scope
main.cpp:8: error: expected `;' before 'hello'
main.cpp:9: error: 'hello' was not declared in this scope
main.cpp:12: error: 'app' was not declared in this scope
main.cpp: At global scope:
main.cpp:4: warning: unused parameter 'argc'
main.cpp:4: warning: unused parameter 'argv'
make[1]: *** [main.o] Error 1
make[1]: Leaving directory `/root/Qt4/imageLoader/src'
make: *** [sub-src-make_default] Error 2
Tranquality imageLoader # qmake
Tranquality imageLoader # make
cd src && make -f Makefile
make[1]: Entering directory `/root/Qt4/imageLoader/src'
g++ -c -pipe -O2 -pipe -D_REENTRANT -Wall -W -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -I. -o main.o main.cpp
main.cpp:13:3: warning: no newline at end of file
g++ -o ../bin/imageloader main.o -L/usr/lib64/qt4 -lQtCore -L/usr/lib64 -L/usr/lib64/qt4 -lz -lm -ldl -lpthread
main.o: In function `main':
main.cpp:(.text+0x25): undefined reference to `QApplication::QApplication(int&, char**, int)'
main.cpp:(.text+0x4d): undefined reference to `QPushButton::QPushButton(QString const&, QWidget*)'
main.cpp:(.text+0x83): undefined reference to `QWidget::resize(QSize const&)'
main.cpp:(.text+0x98): undefined reference to `QApplication::exec()'
main.cpp:(.text+0xa2): undefined reference to `QPushButton::~QPushButton()'
main.cpp:(.text+0xaa): undefined reference to `QApplication::~QApplication()'
main.cpp:(.text+0xc0): undefined reference to `QApplication::~QApplication()'
main.cpp:(.text+0xd3): undefined reference to `QPushButton::~QPushButton()'
collect2: ld returned 1 exit status
make[1]: *** [../bin/imageloader] Error 1
make[1]: Leaving directory `/root/Qt4/imageLoader/src'
make: *** [sub-src-make_default] Error 2
|
The same result... |
|
Back to top |
|
|
jawilson n00b
Joined: 03 Apr 2004 Posts: 64 Location: Madison, WI, USA
|
Posted: Sat Apr 28, 2007 2:20 pm Post subject: |
|
|
It looks like your make command is missing a few includes for some reason... here is what my output looks like:
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o main.o main.cpp
g++ -o test main.o -L/usr/lib/qt4 -lQtGui -L/usr/lib/mysql -L/usr/lib/qt4 -L/usr/lib -lpng -lSM -lICE -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz -lm -ldl -lpthread
What does your *.pro file look like? Here is mine:
Code: | TEMPLATE = app
TARGET = test
DEPENDPATH += .
INCLUDEPATH += .
# Input
SOURCES += main.cpp
|
|
|
Back to top |
|
|
josko Tux's lil' helper
Joined: 02 Mar 2007 Posts: 91
|
Posted: Sun Apr 29, 2007 8:09 pm Post subject: |
|
|
imageLoader.pro Quote: | SUBDIRS += src
TEMPLATE = subdirs
CONFIG += warn_on \
qt \
thread
|
subdirs/src.pro Quote: |
SOURCES += main.cpp
TEMPLATE = app
CONFIG += warn_on \
thread \
qt
TARGET = ../bin/imageloader
QT -= gui
|
These are mine |
|
Back to top |
|
|
jawilson n00b
Joined: 03 Apr 2004 Posts: 64 Location: Madison, WI, USA
|
Posted: Sun Apr 29, 2007 9:27 pm Post subject: |
|
|
So, at this point I would probably start getting rid of anything extraneous, starting with the QT -= gui line. All of the config options should be ok (I've never used the thread one, but I wouldn't think it would contribute to this problem). I'm willing to bet that removing the QT -= gui fixes it, since according to the qmake manual, it provides all of the gui elements needed, including QApplication and QPushButton, and is included by default. Try that, and report back if it doesn't fix it (and if it does, the subject should be marked solved! ) |
|
Back to top |
|
|
josko Tux's lil' helper
Joined: 02 Mar 2007 Posts: 91
|
Posted: Mon Apr 30, 2007 10:34 am Post subject: |
|
|
I'd bet with you that it fixes it.
Editing this message soon; reboot to gentoo in 10 sec.
-edit
That as it.
Turns out to be really stupid, it is caused by the used template... |
|
Back to top |
|
|
|