Results 1 to 8 of 8

Thread: Compiling errors - can't find the libraries

  1. #1
    Join Date
    May 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Compiling errors - can't find the libraries

    I've been trying to get qt (there seems to be both qt3 and qt4) to work properly in Ubuntu 10.4. First I installed qt with just the libraries, which I installed through the command line, then I tried removing those and installing the entire qt development environment through the ubuntu software center (though I really don't need the whole thing, I really prefer to program through the command line), but nothing seems to make any difference. Here's the problem I'm having. qmake works completely fine, but when I try the make command on a simple qt program I get:

    Qt Code:
    1. g++ -c -pipe -g -Wall -W -O2 -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/linux-g++ -I. -I. -I/usr/include/qt3 -o main.o main.cpp
    2. main.cpp:1:25: error: QApplication: No such file or directory
    3. main.cpp:2:24: error: QPushButton: No such file or directory
    To copy to clipboard, switch view to plain text mode 

    And then of course a bunch of other errors as a result of those. The basic script I'm using is as follows:

    Qt Code:
    1. #include <QApplication>
    2. #include <QPushButton>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7.  
    8. QPushButton hello("Hello world!");
    9. hello.resize(100, 30);
    10.  
    11. hello.show();
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    It seems that it can't find the qt libraries, but the paths in the Makefile are correct, as far as I can tell - though they point to qt3 and not qt4 for some reason.

    Qt Code:
    1. LIBS = $(SUBLIBS) -L/usr/share/qt3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm -lpthread
    To copy to clipboard, switch view to plain text mode 
    What am I doing wrong?
    Last edited by magelet; 23rd May 2010 at 16:37.

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Compiling errors - can't find the libraries

    It looks more like a missing include file to me. It's trying to open QApplication through the #include <QApplication> statement, and it can't find a file by that name in any of the include paths listed.

    Check your include directories to see if they contain any such filename, and either add it to your INCLUDES project file variable, or modify your QMAKESPEC *.conf file to use the correct path to Qt.

    Despite advice to avoid such usage, I normally just say '#include <Qt/QtGui>' and grab the whole UI in one gulp. I've never noticed distressingly long compile times using this approach.

  3. #3
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Compiling errors - can't find the libraries

    Obvious spotted problem:
    -L/usr/share/qt3/lib
    -I/usr/share/qt3/mkspecs/linux-g++
    -I/usr/include/qt3

    And you use Qt4 code.

  4. #4
    Join Date
    May 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Compiling errors - can't find the libraries

    Check your include directories to see if they contain any such filename, and either add it to your INCLUDES project file variable, or modify your QMAKESPEC *.conf file to use the correct path to Qt.
    Obvious spotted problem:
    -L/usr/share/qt3/lib
    -I/usr/share/qt3/mkspecs/linux-g++
    -I/usr/include/qt3
    Yes, I realized that. My question is, how do I fix it? How I reroute it to qt4? Where is the QMAKESPEC *.conf file? And how do I check the include directories? Sorry for being so ignorant, but I really just started trying to work with qt yesterday....

    I tried adding the following to ~/.bashrc:

    Qt Code:
    1. export QTDIR=/usr/share/qt4
    2. export QMAKESPEC=linux-g++
    To copy to clipboard, switch view to plain text mode 

    But then when I try qmake, it repeatedly outputs QFile:: open: No file name specified. And if I remove the QTDIR line, it tells me (because I removed qt3):

    Qt Code:
    1. Could not find mkspecs for your QMAKESPEC after trying:
    2. /usr/mkspecs
    3. /usr/share/qt3/mkspecs
    4. /usr/share/qt3
    To copy to clipboard, switch view to plain text mode 

    Please help?

    edit: I tried setting QMAKESPEC=/usr/share/qt4/mkspecs/linux-g++ but now I get:

    Qt Code:
    1. Project LOAD(): Feature qt_config cannot be found.
    To copy to clipboard, switch view to plain text mode 

    I hope I didn't screw something up when I removed qt3....
    Last edited by magelet; 23rd May 2010 at 18:01.

  5. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Compiling errors - can't find the libraries

    Qt4 and Qt3 run very well next to eachother.
    You should not have to do anything else besides installing either version.

    All you need to do is make sure that you use the correct qmake version.
    The paths to qmake should be in your $PATH.

  6. #6
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Compiling errors - can't find the libraries

    At the console, say 'which qmake'. If the answer comes back that it's living in a qt3 subdirectory, that's where your problem lies; you'll have to locate your qt4 installation area and change your PATH so it finds that one first.

    Your qmakespec files are located at $QTDIR/mkspecs. There's a subdirectory for each system - in your case, there will be one called linux-g++. Below that will be a qmake.conf file containing paths and other system-specific settings used by the makefiles qmake generates.

    But I wouldn't even mess with that until you've sorted out your qt3/qt4 issues, which is where your problem seems to lie.

  7. #7
    Join Date
    May 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Compiling errors - can't find the libraries

    Ok.... this is the current situation. It seems I've actually taken a step backward, and now qmake doesn't work... it just repeatedly displays the following, until I manually stop it:

    QFile:: open: No file name specified.

    ??

  8. #8
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Compiling errors - can't find the libraries

    I think it's better to check which environment variables you changed and set them back to their original values.
    Maybe reinstall both Qt3 and Qt4

Similar Threads

  1. Replies: 1
    Last Post: 15th April 2010, 19:05
  2. errors with compiling qt-embedded-linux-opensource-4.4.3
    By dycjiaoda in forum Installation and Deployment
    Replies: 4
    Last Post: 17th April 2009, 15:56
  3. C++ Compiling Errors when use Visual Studio 6.0
    By seguprasad in forum General Programming
    Replies: 1
    Last Post: 3rd February 2009, 11:47
  4. Link errors when linking chained libraries on windows
    By darkadept in forum Qt Programming
    Replies: 5
    Last Post: 26th May 2008, 14:52
  5. compiling errors when using opengl and debug
    By invictus in forum Newbie
    Replies: 3
    Last Post: 31st March 2008, 06:16

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.