Thread: unable to get simple program working

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    2

    unable to get simple program working

    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:
    Code:
    /* 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:
    Code:
    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

  2. #2
    Registered User
    Join Date
    Oct 2003
    Posts
    2
    Hi folks !

    I got it.

    If the compiler's output is something like:
    Code:
    : undefined reference to `QApplication::QApplication[in-charge](int&, char**)'
    then it's just that two libs (for example qt2 & qt3) are conflicting.

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

    Now it should work.

    greetings
    tom

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 09-07-2008, 11:38 PM
  2. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  3. Replies: 1
    Last Post: 12-30-2007, 10:08 AM
  4. simple frontend program problem
    By gandalf_bar in forum Linux Programming
    Replies: 16
    Last Post: 04-22-2004, 06:33 AM
  5. Simple Program not working right (in C)
    By DruzeTito in forum C Programming
    Replies: 5
    Last Post: 06-01-2002, 10:14 PM