ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
[ben@localhost:~/src/qt]$ qmake -project
[ben@localhost:~/src/qt]$ qmake
[ben@localhost:~/src/qt]$ make
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.2.3/include -o main.o main.cpp
main.cpp:21:2: warning: no newline at end of file
g++ -o qt main.o -L/usr/X11R6/lib -lXext -lX11 -lm
main.o(.text+0x1d): In function `main':
: undefined reference to `QApplication::QApplication[in-charge](int&, char**)'
main.o(.text+0x30): In function `main':
: undefined reference to `QString::QString[in-charge](char const*)'
main.o(.text+0x44): In function `main':
: undefined reference to `QPushButton::QPushButton[in-charge](QString const&, QWidget*, char const*)'
main.o(.text+0x5c): In function `main':
: undefined reference to `QString::shared_null'
main.o(.text+0x67): In function `main':
: undefined reference to `QStringData::deleteSelf()'
main.o(.text+0x77): In function `main':
: undefined reference to `QPushButton::resize(int, int)'
main.o(.text+0x80): In function `main':
: undefined reference to `QApplication::setMainWidget(QWidget*)'
main.o(.text+0x88): In function `main':
: undefined reference to `QWidget::show()'
main.o(.text+0x90): In function `main':
: undefined reference to `QApplication::exec()'
main.o(.text+0x9b): In function `main':
: undefined reference to `QPushButton::~QPushButton [in-charge]()'
main.o(.text+0xa3): In function `main':
: undefined reference to `QApplication::~QApplication [in-charge]()'
main.o(.text+0xe5): In function `main':
: undefined reference to `QApplication::~QApplication [in-charge]()'
main.o(.text+0xf3): In function `main':
: undefined reference to `QString::shared_null'
main.o(.text+0xfe): In function `main':
: undefined reference to `QStringData::deleteSelf()'
main.o(.text+0x127): In function `main':
: undefined reference to `QPushButton::~QPushButton [in-charge]()'
main.o(.gnu.linkonce.r._ZTV6QGList+0xc): undefined reference to `QGList::clear()'
main.o(.gnu.linkonce.r._ZTV6QGList+0x10): undefined reference to `QGList::~QGList [in-charge]()'
main.o(.gnu.linkonce.r._ZTV6QGList+0x14): undefined reference to `QGList::~QGList [in-charge deleting]()'
main.o(.gnu.linkonce.r._ZTV6QGList+0x18): undefined reference to `QPtrCollection::newItem(void*)'
main.o(.gnu.linkonce.r._ZTV6QGList+0x20): undefined reference to `QGList::compareItems(void*, void*)'
main.o(.gnu.linkonce.r._ZTV6QGList+0x24): undefined reference to `QGList::read(QDataStream&, void*&)'
main.o(.gnu.linkonce.r._ZTV6QGList+0x28): undefined reference to `QGList::write(QDataStream&, void*) const'
main.o(.gnu.linkonce.r._ZTI6QGList+0x8): undefined reference to `typeinfo for QPtrCollection'
collect2: ld returned 1 exit status
make: *** [qt] Error
I am running Slackware -currnet, with qt-3.2.2 and gcc-3.3.2. Does anyone know what is wrong and how I can get this to compile?
The makefile qmake creates relys on the environment variable $QTDIR, which wasnt set on my system. So if you do a "qmake -project" when the variable isnt set, it will create a nonworking makefile. You need to do a, "export QTDIR=/usr/lib/qt3", (or wherever your QT3 is installed to), then do a "qmake -project", and "qmake", and "make, then it should build. Also, make sure you name the source file main.cpp and have it in its own directory.
To start with it didn't find qvfbhdr.h, because on the
Debian Sarge this file is not included in qt3... Now
I get loads of error messages, the first one being:
undefined reference to `QApplication::QApplication
locate libqt.so to see if you have it. If not, look for libqt-mt (linker option would be -mqt-mt). The difference is that qt-mt is multithreaded.
Quote:
undefined reference to `QApplication::QApplication
Any ideas, please?
The compilation line definitelly misses -lqt (or -lqt-mt). You need it. Look at my package list:
Code:
mara@mara:~$ dpkg-query -l 'qt*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-==============-============================================
un qt-designer <none> (no description available)
un qt-designer-do <none> (no description available)
un qt-doc <none> (no description available)
ii qt3-assistant 3.3.4-3 The Qt3 assistant application
ii qt3-designer 3.3.4-3 Qt3 Designer
ii qt3-dev-tools 3.3.4-3 Qt3 development tools
ii qt3-doc 3.3.4-3 Qt3 API documentation
ii qt3-linguist 3.3.4-3 The Qt3 Linguist
un qt3-linquist <none> (no description available)
un qt3-tools <none> (no description available)
It looks you need qt3-dev-tools.
Quote:
If someone could tell what to do, something which
would look like:
(I don't understand Makefiles at all, and I'm not sure
how to set $SOMETHING variables, either... I know, I'm
hopeles... :-( )
I think you don't want to know the commands this time. Qt requires not only
just g++ (with options), but also usage of moc and uic. The makefiles are quite complicated.
In your case it should be, using Qt standards, quite simple. Please post the makefile you get after running qmake.
This works but it's incredibly slow... About 5 seconds to re-compile 10 lines of code
with one little modification in it...
Well, typing "make" is always slower than typing "g++ <something>", but sometimes it's
only marginally slower. This one is horrible. How long it will take to compile heavier
programs doesn't bear thinking of.
By the way, I tried including -lqt in the g++ command line options, I just didn't include
it here because it didn't work. I tried quite a few permutations (eg changing -L to -I)
but I didn't find any way to make g++ run from the command line with this program.
Hello slackware people!!!
I've seen the post, and i decided try the tutorials as a way to remember those times when younger i used to compile manually programs, (4 years ago) and as i can see things have changed...
Anyway, I've been having the same problem, because my linker didn't work fine, until i replace the old-style "-lqt3" for "-lqt-mt". Actually i don't know what "mt" tag means but the next command line compiled all tutorials.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.