Results 1 to 3 of 3

Thread: problem with include files

  1. #1
    Join Date
    Dec 2006
    Location
    Tonbridge Kent UK
    Posts
    2
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question problem with include files

    Hello, this is my first post and as usual it starts with a problem.
    This is my first day of looking at QT (QT4) and I'm quite excited about it but I haven't really got very far.
    (I'm using Ubuntu Linux and QT4 which I downloaded yesterday to evaluate.)
    I wonder if anyone can help.
    My problem is that when I compile a simple hello world I get: "QApplication: No such file or directory" and the same for the QPushButton file header.

    The cpp file has:

    #include <QApplication>
    #include <QPushButton>

    The code is very simple - I copied from a tutorial.

    My PATH variable includes the following:
    /usr/local/Trolltech/Qt-4.2.2/include:/usr/local/Trolltech/Qt-4.2.2/:/usr/local/Trolltech/Qt-4.2.2/bin

    Both of the header files are actually in .../include/QtGui/ so for the for the compiler to find them I would imagine that that path should be in $PATH - but that seems like far too much work really. So I must be missing something that enables the complier to look in sub directories. Or perhaps I'm missing something else that is obvious to everyone other than me.
    Any help will be greatly appreciated.
    thanks a lot

    john

  2. #2
    Join Date
    Dec 2006
    Posts
    9
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: problem with include files

    Hi,

    did you use qmake to set up a project file as described in the same tutorial?

    If not run "qmake -project" followed "qmake" and then "make" in the directory your project is in. This should work without setting up any path to the header files.

    Else if the project doesn't work try to tell the compiler explicit where it finds the headers by appending

    -I/usr/local/Trolltech/Qt-4.2.2/include/QtCore -I/usr/local/Trolltech/Qt-4.2.2/include/QtGui -I/usr/local/Trolltech/Qt-4.2.2/mkspecs/linux-g++ -I/usr/local/Trolltech/Qt-4.2.2/include

    to your g++ calls. When you link everything together you also need to specify which libraries to use for this. Append
    -L/usr/local/Trolltech/Qt-4.2.2/lib -lQtGui -lQtCore

    Now it should compile and link without errors.

    If you get linker errors when you start the application you need to set the path to the Qt libraries in the LD_LIBRARY_PATH environment variable.

    You can also add the above includes to the CPLUS_INCLUDE_PATH variable. Btw. the PATH variable should only contain paths to binaries. The compiler doesn't look there for anything.

    Hope it helps.

  3. The following user says thank you to ggrinder for this useful post:

    JR (22nd December 2006)

  4. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: problem with include files

    You only need to add the path to the Qt's bin directory to locate qmake, moc and other Qt tools (others are not needed) to the PATH env variable:
    /usr/local/Trolltech/Qt-4.2.2/bin
    Are you using qmake? If Qt is installed correctly, (for a simple project) it should be as simple as:
    $ qmake -project
    $ qmake
    $ make
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    JR (22nd December 2006)

Similar Threads

  1. QApplication: no such file or directory
    By jochen_r in forum Newbie
    Replies: 13
    Last Post: 15th November 2008, 22:46
  2. Problem converting .ui files from Qt3 to 4
    By Amanda in forum Qt Programming
    Replies: 6
    Last Post: 28th October 2006, 05:34
  3. problem with an include
    By mickey in forum General Programming
    Replies: 1
    Last Post: 20th July 2006, 14:45
  4. Replies: 7
    Last Post: 2nd June 2006, 13:48
  5. use button from another Window
    By raphaelf in forum Qt Programming
    Replies: 11
    Last Post: 2nd March 2006, 21:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.