2017-05-27 164 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