make, compiling and linking

make, compiling and linking

Post by Ken Sodema » Fri, 02 Oct 1998 04:00:00





>Hi.

>DAMN!

>Im trying to compile a little program with Qt but i cant get the linking
>right. Im very very mad!

Very mad, and not very helpful.  Next time, try providing some details.
For example, what is the link error you are getting?  What compiler
switches are you using? etc.

Quote:

>Im trying to use make and I hate make. Is there some way to create the
>makefile without fuzz?

None of my Makefile's ever have 'fuzz'.  Perhaps you mean 'fuss'? :)

Anyhow, make files are usually pretty simple, especially for simple programs.
Look at and read the info files on make, and you should know all you
need to know.

As far as QT is concerned, if you are using the slots and signals in your
simple program, setting up the Makefile can be a little hairy the first
time, since the QT tutorial really glosses over this subject.  There are
several ways to deal with the MOC.  What I do is create a rule for the
MOC output, and then #include the .moc file output into the .C (or .cpp
if you prefer) file, and list the .moc file as a dependance for the
.o file with which it should be associated.  See included example Makefile,
and note the class declared in lcdrange.h uses signals and slots, and
thus needs to be run through the MOC.  lcdrange.C then contains a
#include lcdrange.moc.

Finally, Troll Tech offers a program called TMAKE that will make the
Makefile for you, given that you feed TMAKE the proper information.
goto: http://www.troll.no/freebies/tmake.html

However, I suggest that you learn how to deal with Makefiles first, as
you will probably have to at some point in your life anyhow (besides,
they are not hard).

Hope this helped;

--

http://www.pcii.net/~stuffel
NASCAR fan, Packer fan | Go #23, #24, #36 | Go Pack!!

--------Makefile-------------

#--------------------------------------------------------------------------
#  Make the example program in chapter 12 of the tutorial.
#

##-------------------------------------------------------------------------
CC = g++
MOC = moc
CFLAGS = -I/usr/lib/qt/include -Wall -ansi -pedantic
LDFLAGS = -lqt

##-------------------------------------------------------------------------

### Objects & Targets
OBJS = cannon.o lcdrange.o main.o shot.o
TARGET = ch12

### Main Rule
all : $(TARGET)

### Implicit Rules
.C.o:
        $(CC) -c $(CFLAGS) $<

%.moc: %.h

### Compile Rules
cannon.o : cannon.C cannon.h cannon.moc

lcdrange.o : lcdrange.C lcdrange.h lcdrange.moc

main.o : main.C lcdrange.h

shot.o : shot.C shot.h

### Targets
$(TARGET) : $(OBJS)

.PHONY : clean
clean:
        rm -f *.moc $(OBJS) $(TARGET) core

 
 
 

make, compiling and linking

Post by David M. Co » Fri, 02 Oct 1998 04:00:00




>Im trying to use make and I hate make. Is there some way to create the
>makefile without fuzz?

Troll Tech has a tool for creating makefiles.  See

http://www.troll.no/freebies/tmake.html

But it may make very fuzzy makefiles, I don't know.

Dave Cook