3

I am trying "Linux Kernel Module Programming - Compiling the Module" as in this youtube video.

First I created a hello.c program. Then I used the command #gedit Makefile. It opens a window which is empty in gedit.

I tried to copy the same commands but running make command

it showed an error:

make:*** No rule to make target 'make', needed by 'all'. Stop. 

Searching some Ubuntu forms I tried:

sudo apt-get install build essentials 
sudo apt-get install make
sudo apt-get install autoconf automake

Every time I executed this command some packages got installed.

I went and checked in:

root@ubuntu: /lib/modules/3.5.0-17-generic/build

I can see 'Makefile' when typed ls command, but still I have the same problem make command is not still working as gedit Makefile command open a blank editor.

Raady
  • 151

1 Answers1

1

As Gerhard says, it's a problem with the makefile.

In the video, the author has prepared a makefile, and so you need to copy his instructions into your own make file.

I tried his instructions myself and made sure to copy the Makefile exactly, which worked well, so if you check your file carefully for errors, you will hopefully find it. Here's my file, that works, you could save some time by copying it instead.

obj-m += hello.o

KDIR=/usr/src/linux-headers-3.5.0-22-generic/

all:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

clean:
rm -rf *.ko *.o *.mod.* *.symvers *.order

One thing to watch out for with Makefiles, that isn't mentioned in the video, is that in this part

all:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

The $(MAKE) line must be indented with a TAB, not spaces.

user50849
  • 492
  • 2
  • 7
  • 20