2017-05-27 163 views
0

我在其他的LinK +开发linux内核模块。我的开发机器安装了Linux Mint 18,操作系统内核版本为4.4.xx.为了测试,我想将内核模块部署到内核版本为3.16.xx的Debian机器上(在虚拟机中)。其他内核的Linux内核模块开发编译

链接+有一个名为“编译为其他内核”的选项(见下图)

enter image description here

当我按下该按钮,一个对话框问我指向内核源位置。我已经从https://www.kernel.org/下载了内核版本3.16.xx,然后指向从该存档提取的文件。

make命令的输出是这样的:

**** 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' 

我做了什么错?

回答

1

我已经从https://www.kernel.org/下载了内核版本3.16.xx,然后指向从该存档提取的文件。

如果您只有原始来源,则无法为某些内核编译模块。你需要点IDE来配置和部分构建内核。实际上,为某些内核版本构建模块所需的所有文件都位于编译内核的kbuild目录中,并已安装到/ lib/modules/版本/kbuild中。有Linux的kbuild- 版本https://packages.debian.org/jessie/kernel/linux-kbuild-3.16)封装,一些文件https://packages.debian.org/jessie/amd64/linux-kbuild-3.16/filelist和Linux的包头中版本https://packages.debian.org/jessie/linux-headers-3.16.0-4-amd64),其包括Module.symvers(https://packages.debian.org/jessie/amd64/linux-headers-3.16.0-4-amd64/filelist):

/usr/src目录/ Linux的头文件3.16.0-4-amd64/Module.symvers

+0

我该如何“配置和部分构建内核”而无需替换我的当前内核? – TGeorge

+0

George02,我不知道LinK + IDE及其指向其他内核的目录需求。我知道Debian中的软件包,它包含在本地构建内核模块所需的所有文件(使用2个软件包名称更新答案;它们允许使用https://www.kernel.org/doc/Documentation/kbuild/modules.txt本地构建内核模块'make -C/lib/modules/__ VERSION __/build M = $ PWD')。它们安装在不同的目录中,我不知道如何将它们复制并组织到LinK +的单个目录中。 – osgx

+1

@ George02,只需安装模块,在虚拟Debian中构建模块,并在虚拟机中创建模块,并使用'make -c/lib/modules /''uname -r \'/ build M = $ PWD'和' make -C/lib/modules/\'uname -r \'/ build M = $ PWD modules_install';或者检查'/ lib/modules/\'uname -r \'/ build'目录内的内容并递归地(带下面的链接)将其复制到主机,然后指向LinK +中的副本。 – osgx