Click to See Complete Forum and Search --> : need help with a Makefile


Bob54325
02-02-2002, 10:02 AM
I'm developing a KDE app with this Makefile:


CFLAGS=-lX11 -lXext -lqt -lkdecore -lkdeui -L$(QTDIR)/lib -L/usr/X11R6/lib -I$(QTDIR)/include -L/usr/lib/kde2
-ldl

quizzer: quizCore.o editCardsCore.o main.o quizzer.o
g++ $(CFLAGS) -o quizzer quizCore.o editCardsCore.o main.o quizzer.o

quizCore.o: quizCore.h quizCore.cpp
g++ $(CFLAGS) -c quizCore.cpp

quizCore.h: quizCore.ui
$(QTDIR)/bin/uic quizCore.ui -o quizCore.h

quizCore.cpp: quizCore.ui quizCore.h
$(QTDIR)/bin/uic quizCore.ui -i quizCore.h -o quizCore.cpp

editCardsCore.o: editCardsCore.h editCardsCore.cpp
g++ $(CFLAGS) -c editCardsCore.cpp

editCardsCore.h: editCardsCore.ui
$(QTDIR)/bin/uic editCardsCore.ui -o editCardsCore.h

editCardsCore.cpp: editCardsCore.ui editCardsCore.h
$(QTDIR)/bin/uic editCardsCore.ui -i editCardsCore.h -o editCardsCore.cpp

main.o: main.cpp
g++ $(CFLAGS) -c main.cpp

quizzer.o: quizzer.cpp quizzer.h
g++ $(CFLAGS) -c quizzer.cpp

And I got these errors:


quizCore.o: In function `quizCore::quizCore(QWidget *, char const *, unsigned int)':
quizCore.o(.text+0x20): undefined reference to `quizCore virtual table'
quizCore.o(.text+0x2a): undefined reference to `quizCore::QPaintDevice virtual table'
quizCore.o(.text+0x6c): undefined reference to `quizCore::tr(char const *)'
quizCore.o(.text+0x1a9): undefined reference to `quizCore::tr(char const *)'
quizCore.o(.text+0x323): undefined reference to `quizCore::tr(char const *)'
quizCore.o: In function `quizCore::~quizCore(void)':
quizCore.o(.text+0x48c): undefined reference to `quizCore virtual table'
quizCore.o(.text+0x496): undefined reference to `quizCore::QPaintDevice virtual table'
editCardsCore.o: In function `editCardsCore::editCardsCore(QWidget *, char const *, unsigned int)':
editCardsCore.o(.text+0x23): undefined reference to `editCardsCore virtual table'
editCardsCore.o(.text+0x2d): undefined reference to `editCardsCore::QPaintDevice virtual table'
editCardsCore.o(.text+0x6f): undefined reference to `editCardsCore::tr(char const *)'
editCardsCore.o(.text+0x23a): undefined reference to `editCardsCore::tr(char const *)'
editCardsCore.o(.text+0x28c): undefined reference to `editCardsCore::tr(char const *)'
editCardsCore.o(.text+0x468): undefined reference to `editCardsCore::tr(char const *)'
editCardsCore.o(.text+0x61d): undefined reference to `editCardsCore::tr(char const *)'
editCardsCore.o(.text+0x9cb): more undefined references to `editCardsCore::tr(char const *)' follow
editCardsCore.o: In function `editCardsCore::~editCardsCore(void)':
editCardsCore.o(.text+0x10ec): undefined reference to `editCardsCore virtual table'
editCardsCore.o(.text+0x10f6): undefined reference to `editCardsCore::QPaintDevice virtual table'
quizzer.o: In function `Quizzer::Quizzer(int, QWidget *, char const *)':
quizzer.o(.text+0x52): undefined reference to `Quizzer virtual table'
quizzer.o(.text+0x5c): undefined reference to `Quizzer::QPaintDevice virtual table'
quizzer.o(.text+0x66): undefined reference to `Quizzer::KXMLGUIBuilder virtual table'
quizzer.o(.text+0x76): undefined reference to `Quizzer::KXMLGUIClient virtual table'
quizzer.o: In function `Quizzer::~Quizzer(void)':
quizzer.o(.text+0x16c): undefined reference to `Quizzer virtual table'
quizzer.o(.text+0x176): undefined reference to `Quizzer::QPaintDevice virtual table'
quizzer.o(.text+0x180): undefined reference to `Quizzer::KXMLGUIBuilder virtual table'
quizzer.o(.text+0x190): undefined reference to `Quizzer::KXMLGUIClient virtual table'
collect2: ld returned 1 exit status
make: *** [quizzer] Error 1


I didn't include the source code since I'm pretty sure this is a Makefile problem (am I not including the right libraries?). Please help. Thanks.

bwkaz
02-02-2002, 10:50 AM
Originally posted by Bob54325:
<STRONG>CFLAGS=-lX11 -lXext -lqt -lkdecore -lkdeui -L$(QTDIR)/lib -L/usr/X11R6/lib -I$(QTDIR)/include -L/usr/lib/kde2
-ldl</STRONG>

I think it's a problem with Qt, since all the undefined references are Q-something. So looking at your CFLAGS, there are a couple things.

First, I think it'd make more sense to separater the CFLAGS (for compiling) from the LFLAGS (for linking). Put the -l's and the -L's in a separate LFLAGS variable, and don't include it in the compiling lines. Then leave the -I in CFLAGS, and only put that on the compiling lines (not the linking one).

But that wouldn't cause your problem. What version of Qt are you developing for? If you're developing for Qt 3 but have 2.x.x installed in $QTDIR, that will cause a problem like this.

Or, looking at it more, it might be the fact that you're using parens in the variables. Try it with $QTDIR instead of $(QTDIR), and see if that helps.

You also may want to add include paths for KDE headers ($KDEDIR/include) and X headers (/usr/X11R6/include). It doesn't look like that's the cause of this, but it will help later.

Bob54325
02-02-2002, 11:36 AM
Thank you for answering so quickly. However, I did what you told me and I'm still having the same problem. I am developing for QT 2 on QT 2 so I don't think that is the problem.

Bob54325
02-02-2002, 11:39 AM
Okay, I have it working. I used Trolltech's tmake. Thank you.

jkm
02-02-2002, 03:41 PM
At first glance, it would appear you are not running "moc" on your source files.