5

So I am trying to write a simple hello module no need to say a newbie :)

however while following steps to create a make file - what I saw was I didnot have build folder at uname -r/build so I created one - not sure that itself should be problem as in instead of creating build folder if I am suppose to download some package ?

Also looking online there is solution which says I need to do below steps

prepare-kernel-sources cd /usr/src/linux - now turns out I dont i have linux folder too cp -rf include/generated/* include/linux/

make: Entering directory `/lib/modules/2.6.32-5-amd64/build'
make: *** No rule to make target `modules'.  Stop.
make: Leaving directory `/lib/modules/2.6.32-5-amd64/build'

I have tried to install following packages - only the highlighted ones goes through rest gives error

**apt-get install linux-headers-$(uname -r)**  goes through
apt-get install Linux-headers-generic
apt-get install build-essentials
apt-cache search linux-headers-$(uname -r)
apt-get install kernel-source-$(uname -r)
**apt-get source linux-image-$(uname -r)**   goes through

Can someone please help ?

thedreamer
  • 319
  • 1
  • 5
  • 13
  • Do you have the kernel development packages installed on your system? – Etan Reisner Oct 29 '15 at 21:58
  • @EtanReisner - I have updated the question with things I have tried to install post the error based on research online - but majority of things are giving me error - ln btw flavor is debian on which I am trying – thedreamer Oct 29 '15 at 22:27
  • And did you try compiling again after installing those two packages? (I doubt `apt-get source` is helpful here though as that probably just grabbed the sources used to build the Debian package itself.) – Etan Reisner Oct 30 '15 at 01:48
  • @EtanReisner - I have updated the answer - turns out it was because of missing system link . I have posted the answer if someone else trips on same issue – thedreamer Oct 30 '15 at 05:15

2 Answers2

5

Finally I found the answer - Missing part was establishing system link.

Below steps solved the issue.

apt-get install linux-headers 
ln -s /usr/src/linux-headers-2.6.32-5-amd64/ /lib/modules/2.6.32-5-amd64/build
thedreamer
  • 319
  • 1
  • 5
  • 13
  • 1
    You shouldn't have to do that yourself. That should be part of the linux-headers-2.6.32-5-amd64 package. See [here](https://packages.debian.org/squeeze/amd64/linux-headers-2.6.32-5-amd64/filelist). – Etan Reisner Oct 30 '15 at 13:48
  • Reading package lists... Done Building dependency tree Reading state information... Done Package linux-headers is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'linux-headers' has no installation candidate – EgoPingvina Jul 29 '20 at 11:14
  • Under Opensuse install kernel-default-devel. – spawn Jul 08 '21 at 11:17
0

Directory that contains Makefile and source was named with space between. changed space with underscore(_). Worked.