Tarida George
Tarida George

Reputation: 1303

Linux Kernel Module development compile for other kernel

I'm using LinK+ in other to develop a linux kernel module. My development machine has a Linux Mint 18 installed operating system with kernel version 4.4.xx. For testing I want to deploy the kernel module to a Debian machine(in a virtualbox) which has a kernel version 3.16.xx.

LinK+ has an option called "Compile for other kernel" (see image below)

enter image description here

When I press that button a dialog ask me to point to Kernel Source Location. I've downloaded kernel version 3.16.xx from https://www.kernel.org/ and then pointed to extracted files from that archive.

The output of the make command is this:

**** Build of configuration Debug for project VMDD ****

make --makefile=Makefile --directory=KERN_SRC modules 
make: Entering directory '/home/george/linkProjects/VMDD/KERN_SRC'
make -C /home/george/kernels/linux-3.16.43/ M=/home/george/linkProjects/VMDD/KERN_SRC modules
make[1]: Entering directory '/home/george/kernels/linux-3.16.43'

  WARNING: Symbol version dump ./Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  /home/george/linkProjects/VMDD/KERN_SRC/VMDD.o
/bin/sh: 1: ./scripts/recordmcount: not found
scripts/Makefile.build:263: recipe for target '/home/george/linkProjects/VMDD/KERN_SRC/VMDD.o' failed
make[2]: *** [/home/george/linkProjects/VMDD/KERN_SRC/VMDD.o] Error 127
Makefile:1337: recipe for target '_module_/home/george/linkProjects/VMDD/KERN_SRC' failed
make[1]: Leaving directory '/home/george/kernels/linux-3.16.43'
make[1]: *** [_module_/home/george/linkProjects/VMDD/KERN_SRC] Error 2
make: *** [modules] Error 2
Makefile:8: recipe for target 'modules' failed
make: Leaving directory '/home/george/linkProjects/VMDD/KERN_SRC'

What did I do wrong ?

Upvotes: 0

Views: 2312

Answers (1)

osgx
osgx

Reputation: 94235

I've downloaded kernel version 3.16.xx from https://www.kernel.org/ and then pointed to extracted files from that archive.

You can't compile modules for some kernel if you have only its original source. You need point IDE to configured and partially build kernel. Actually, all files needed to build modules for some kernel version are in kbuild directory of compiled kernel, installed into /lib/modules/version/kbuild. There are linux-kbuild-version (https://packages.debian.org/jessie/kernel/linux-kbuild-3.16) package with some files https://packages.debian.org/jessie/amd64/linux-kbuild-3.16/filelist and linux-headers-version (https://packages.debian.org/jessie/linux-headers-3.16.0-4-amd64) which includes Module.symvers (https://packages.debian.org/jessie/amd64/linux-headers-3.16.0-4-amd64/filelist):

/usr/src/linux-headers-3.16.0-4-amd64/Module.symvers

Upvotes: 1

Related Questions