Can't compile QT App.
I'm trying to compile a little qt test app;
#include <qapplication.h> #include <qwidget.h> #include <qpushbutton.h> int main(int argc, char **argv) { QApplication a(argc, argv); QWidget mainwindow; mainwindow.setMinimumSize(200,100); mainwindow.setMaximumSize(200,100); QPushButton helloworld("Hello World!", &mainwindow); helloworld.setGeometry(20, 20, 160, 60); a.setMainWidget(&mainwindow); mainwindow.show(); return a.exec(); } I've read the QT documentation and I've set my environment variables up as follows; QTDIR=/usr/lib/qt-3.1 PATH=$QTDIR/bin:$PATH MANPATH=$QTDIR/man:$MANPATH LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH CPLUS_INCLUDE_PATH=$QTDIR/include:$CPLUS_INCLUDE_PATH export QTDIR PATH MANPATH LD_LIBRARY_PATH CPLUS_INCLUDE_PATH They all come up correctly when I echo them. When I try to compile using GCC, it spits out a whole load of parse errors and syntax errors in the header files?! If I use g++ it complains; /usr/bin/ld: cannot find -lqt collect2: ld returned 1 exit status Please help, I'm pulling my hair out!! Thanks, Regards... Wolverine |
Moved to the Programming forum
|
ok, so have you actually got the QT header libraries installed?
|
Yeah, all headers are in /usr/lib/qt-3.1/include
|
Quote:
export QTDIR=/usr/lib/qt-3.1 |
I made a mistake in the previous post. The path for QTDIR I mentioned, is (obviously?) incorrect. Sorry about that!
Let me explain: In Debian the Qt files don't get installed in the directories Qt would normally get installed to. This is done to comply with the quite strict rules for Debian packages, in respect to where binaries, header files an libraries are stored. Due to this the Qt way of finding the files would not work in many cases. To solve this The debian Qt packages also install symbolic links to the directories where the actual files are stored, in such a way that the Qt way of doing things will work through these symlinks. The links are placed in a subdirectory of /usr/share. Look there for a subdirectory called "qt" or "qt3" or so, and then use that directory in the QTDIR environment var. So, if you use Qt-2, forget about MANPATH, LD_LIBRARY_PATH and so, and just try: export QTDIR=/usr/share/qt (or, if you use Qt 3) export QTDIR=/usr/share/qt3 Sorry about my mistake in the other post. Hope this time I could help. P.S. Of course, also make sure you have the corresponding development package installed. |
I'm running redhat 8.0, but I've manually upgraded qt and kde, the current qt packages installed are:
qt-3.1.1-6 qt-devel-3.1.1-6 qt-designer-3.1.1-6 Thanks. wolverine |
Since you're trying to dynamically link
to qt the path to libqt needs to be listed in /etc/ld.so.conf edit that file, add the qt/lib directory, run ldconfig and try again... Cheers, Tink |
My /etc/ld.so.conf:
/usr/kerberos/lib /usr/X11R6/lib /usr/lib/sane /usr/lib/wine /usr/lib/qt-3.1/lib I think that last line is what you wanted me to do? It was already there... :confused: |
OK, have re-read the whole thread :}
As for the parse & syntax errors: which version of gcc? As for the linker... chances are that your installation of qt does have the multi-threading enabled, which means that you won't have the single threaded library installed. To work around that: cd /usr/lib/qt-3.1/lib ln -s libqt-mt.so libqt.so If it still nags you, repeat for the other symlinks :} Cheers, Tink |
Thanks for the reply :)
In my /usr/lib/qt-3.1/lib, all the symlinks seem to be alright. Eg: I have libqt.so, libqt-mt.so, libqt-mt.so.3 and libqt-mt.so.3.1 all pointing to libqt-mt.so.3.1.1 As for my version of GCC, I have gcc-3.2.2-5. Thanks again. Wolverine |
Can't say anything conclusive re the
compiler since I'm still on 2.95.3... As for the libraries: I'm starting to be confused ... :) ... in a situation like that what *I* would do to check it's all good: ldconfig -v | grep -i qt Cheers, Tink |
Here's the output from 'ldconfig -v | grep -i qt'
libqthreads.so.0 -> libqthreads.so.0.0.0 libqtmcop.so.1 -> libqtmcop.so.1.0.0 /usr/lib/qt-3.1/lib: libqt-mt.so.3 -> libqt-mt.so.3.1.1 Is that good? :confused: Thanks. Wolverine |
Ummm ... that's a bit odd...
the threads thingies belong to guille.... And finding the libqy-mt should do. I'd suggest you ask at the qt-mailing list. Cheers, Tink |
if u r using qt 3.1, try to use -lqt-mt instead of -lqt, it will work
|
All times are GMT -5. The time now is 03:36 PM. |