Re: including my own .h files....



On Tue, 23 Jan 2001 19:22:34 +0100, Ronald Bultje <rbultje ronald bitfreak net>  said:

> [rbultje tux linux_studio-0.11]$ make
> gcc `gtk-config --cflags` -g -Wall   -c -o tvplug.o tvplug.c

OK.. So we make a tvplug.o here...

> gcc studio.c -o studio `gtk-config --cflags` -g -Wall `gtk-config --libs
> gthread` -L/usr/X11R6/lib -lXv -lXxf86vm -lXxf86dga  -lXaw3d -lXmu -lXt 
> -lSM -lICE -lXext -lX11

But we don't reference it here...

> /home/rbultje/linux_studio-0.11/studio.c:575: undefined reference to
> `create_tv_plug'

So since we didn't reference tvplug.o, the linker did the *reasonable* thing
and said "I can't find the function that's in the .o file you didn't TELL
me about".

The 'gcc' command that does the linking (has '-o studio') has to reference
ALL the objects (.o files, -lwhatver) needed to clean things up.  It has
an *implicit* reference to studio.o because it just compiled studio.c, but
you have to add tvplug.o to the command.

Suggestion:

OBJS=studio.o tvplug.o
OTHERLIBS=    #anything else you need to get it to work here..

.c.o:	gcc -c -g -Wall `gtk-config --cflags` $@

studio: $(OBJS)
	gcc -o studio $(OBJS) `gtk-config --libs` $(OTHERLIBS)

Makes it a *LOT* easier to fix things when you add a third .o ;)

And yes, I've *probably* got flags etc wrong.  This is for *style*.
Tailor to actually work,. ;l)
-- 
				Valdis Kletnieks
				Operating Systems Analyst
				Virginia Tech

Attachment: pgpacMl1KCNOM.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]