Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

First I created a hello.c program. As a second step need to type command #gedit Makefile. It opens a window which is empty in gedit.

I tried to copy the same commands but running make command

its showed 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@unbuntu: /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.

Any help is greatly appreciated.

share|improve this question
    
the error you get point to a mistake in your Makefile, could you paste your Makefile here? – Gerhard Burger Jan 29 '13 at 9:28
    
It seems like you are running make make or something like that (instead of just make). Can you paste the exact command you are executing? – Andrea Corbellini Dec 2 '15 at 19:33

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.