unable to get simple program working [Archive] - C Board

PDA

View Full Version : unable to get simple program working


toom
10-10-2003, 12:51 PM
Hi !

I'm new to C++ and Qt Programming. I just read a book about Qt and now i want starting my programmer carrer ;).

Okay, here is the code of my prog:
/* Just open simple qt-Window */
#include <qapplication.h>
#include <qlabel.h>

int main(int argc, char **argv) {
QApplication *app = new QApplication(argc , argv);
//QLabel *qLabel = new QLabel("<H1>Nettes Proggie<h1>", 0);
//qLabel->show();
//app->setMainWidget(qLabel);
return app->exec();
}
//finish


Very simple, isn't it?
Well i'm using a debian system and i installed the qt2 & qt3 dev-libs via apt-get. They can be found in /usr/inlcude/qt & /usr/include/qt3. I also modified the /etc/ld.so.conf with the apropreate(?) paths and ran ldconfig.
Then I try to compile my prog with the command:
tom@debian:~/eigene dateien/Programmieren/qt-kde Programmierung$ g++ -o prog1 -I /usr/include/qt -lqt prog1.cpp
/tmp/ccyTUIn6.o(.text+0x32): In function `main':
: undefined reference to `QApplication::QApplication[in-charge](int&, char**)'
/tmp/ccyTUIn6.o(.text+0x8e): In function `main':
: undefined reference to `QApplication::exec()'
collect2: ld returned 1 exit status


Unfortunately it doesn't work an i do not understand the compiler's output, since i haven't much experience using the gcc.

I appreciate any suggestions.

thx
tom

toom
10-11-2003, 05:05 AM
Hi folks !

I got it. :D:D:D

If the compiler's output is something like:

: undefined reference to `QApplication::QApplication[in-charge](int&, char**)'
then it's just that two libs (for example qt2 & qt3) are conflicting. :rolleyes:

The solution is very simple: just remove one of the two libs.

Now it should work.

greetings
tom :)