1

I've got homework in Operating Systems course, in which I have to write some module. We use Red Hat 8.0 with customed linux kernel 2.4.18.14. I have a makefile for compiling the module, but I fail getting it to work. the module source code is in snake.c and the makefile is:

KERNELDIR = /usr/src/linux-2.4.18-14custom
include $(KERNELDIR)/.config
CFLAGS = -D__KERNEL__ -DMODULE –I$(KERNELDIR)/include -O -Wall
all: snake.o

The files are in directory /home/user/OS4. When I call make command in that directory it write error:

cc: cannot specify -o with -c or -S and multiple compilations

Can You help me with it? And I'll be glad if you'll explain how the modules compiling work. Thanks

2
  • 1
    There is no gcc invokations in code you presented. Try make -n to get compiler command lines for each file and try to find invokation which has incorrect options (-o with -c, etc). Commented Jun 16, 2015 at 22:03
  • I don't understand whats the problem. the command line I get is: cc -D__KERNEL__ -DMODULE ?I/usr/src/linux-2.4.18-14custom/include -Wall -c -o snake.o snake.c how can I fix it? Commented Jun 16, 2015 at 22:51

1 Answer 1

1
cc -D__KERNEL__ -DMODULE ?I/usr/src/linux-2.4.18-14custom/include -Wall -c -o snake.o snake.c

Note question mark before I letter. The problem is that instead of normal ascii hyphen-minus - (ASCII code: 45), you accidentally got en dash (Unicode 0x2013) -- note that line is little longer.

It is coming from CFLAGS variable:

# CFLAGS = -D__KERNEL__ -DMODULE –I$(KERNELDIR)/include -O -Wall
                                 ^^^ This is en dash

Replace it by regular hyphen - and you should be fine.

(and because this argument doesn't begin with -, gcc treats it not as option but extra source file but -c option does not allow to pass more than one source file)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.