PDA

View Full Version : Compiling errors - can't find the libraries



magelet
23rd May 2010, 16:24
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:


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
main.cpp:1:25: error: QApplication: No such file or directory
main.cpp:2:24: error: QPushButton: No such file or directory

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



#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();
}

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.


LIBS = $(SUBLIBS) -L/usr/share/qt3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm -lpthread
What am I doing wrong?

SixDegrees
23rd May 2010, 16:48
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.

tbscope
23rd May 2010, 17:13
Obvious spotted problem:
-L/usr/share/qt3/lib
-I/usr/share/qt3/mkspecs/linux-g++
-I/usr/include/qt3

And you use Qt4 code.

magelet
23rd May 2010, 17:56
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:


export QTDIR=/usr/share/qt4
export QMAKESPEC=linux-g++

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):



Could not find mkspecs for your QMAKESPEC after trying:
/usr/mkspecs
/usr/share/qt3/mkspecs
/usr/share/qt3


Please help?

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


Project LOAD(): Feature qt_config cannot be found.

I hope I didn't screw something up when I removed qt3....

tbscope
23rd May 2010, 18:15
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.

SixDegrees
23rd May 2010, 18:51
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.

magelet
23rd May 2010, 23:09
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.

??

tbscope
24th May 2010, 08:24
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