LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Can't compile QT App. (https://www.linuxquestions.org/questions/programming-9/cant-compile-qt-app-68018/)

Wolverine 06-25-2003 02:03 PM

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

mcleodnine 06-25-2003 02:09 PM

Moved to the Programming forum

acid_kewpie 06-25-2003 03:20 PM

ok, so have you actually got the QT header libraries installed?

Wolverine 06-25-2003 03:24 PM

Yeah, all headers are in /usr/lib/qt-3.1/include

Hko 06-27-2003 11:04 AM

Quote:

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
Are doing this under Debian? If so, just try:
export QTDIR=/usr/lib/qt-3.1

Hko 06-28-2003 06:02 AM

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.

Wolverine 06-28-2003 09:25 PM

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

Tinkster 06-29-2003 02:41 PM

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

Wolverine 06-30-2003 07:55 PM

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:

Tinkster 07-01-2003 03:17 AM

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

Wolverine 07-03-2003 08:29 PM

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

Tinkster 07-03-2003 08:41 PM

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

Wolverine 07-04-2003 12:40 AM

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

Tinkster 07-04-2003 01:12 AM

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

RalphOO 07-04-2003 09:57 PM

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.