Dhiman, Gaurav (Gaurav.Dhiman@ca.com) wrote: > > Hi, > > I tried what you suggested, but when I run that command it gives a lot > of linking errors saying multiple definations of functions. > > I looked for the same on net and found one simple makefile containing > the following command for linking: > > ld -m elf_i386 -r -o pipe.c fifo.c msg_q.c main.c > > When I include this linking command in my Makefile, it does not give any > error and creates the corresponding .o file for each .c file but does > not create the single relocatable object file through which I can load > or unload the module. I do not get any error with following makefile, > but at the same time it does not link the .o file to make final module. > Please let me know what the problem is > > Also please explain me about -m option of 'ld', whats the use of this > option ? > > I am pasting below my Makefile for your reference > > ****************************************** > Makefile - Starts > ****************************************** > > KERNELDIR = /usr/src/linux-2.4 > > CC = gcc > > include $(KERNELDIR)/include/linux/config.h > > CFLAGS = -I$(KERNELDIR)/include -D__KERNEL__ -DMODULE \ > -O -Wall -c > > LFLAGS = -m elf_i386 -r -o OBJ=main.o pipe.o fifo.o msg_q.o > > ifdef CONFIG_SMP > CFLAGS += -DSMP > endif > > all: driver.o > > driver.o: main.o pipe.o fifo.o msg_q.o > ld $(LFLAGS) main.o pipe.o fifo.o msg_q.o ld $(LFLAGS) $(OBJ) -o $@ instead of : > main.o: main.c > $(CC) $(CFLAGS) main.c > > fifo.o: fifo.c > $(CC) $(CFLAGS) fifo.c > > pipe.o: pipe.c > $(CC) $(CFLAGS) pipe.c > > msg_q.o: msg_q.c > $(CC) $(CFLAGS) msg_q.c put : .c.o: $(OBJ) $(CC) $(CFLAGS) -c $< It is only esthetic :) > > #all: main.o pipe.o fifo.o msg_q.o > # $(CC) $(CFLAGS) main.c pipe.c fifo.c msg_q.c > > clean: > rm -f *.o *~ core > > ****************************************** > Makefile - Ends > ****************************************** -- Amicalement Christophe * GNU/Linux & UNIX developer and network administrator * Membre RotomaLUG (http://www.rotomalug.org) * Registered User #271267 * Email: c.lucas@ifrance.com * Web Site: http://odie.mcom.fr/~clucas/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/