编译 VirtualBox 内核模块失败 Lubuntu 16.04

编译 VirtualBox 内核模块失败 Lubuntu 16.04

我正在尝试在全新安装的 lubuntu 16.04 中安装 virtualbox,但是出现以下错误:

anonprophet@anonbook:~/Downloads$ sudo dpkg -i virtualbox-5.0_5.0.20-106931-Ubuntu-xenial_amd64.deb 
[sudo] password for anonprophet: 
(Reading database ... 155035 files and directories currently installed.)
Preparing to unpack virtualbox-5.0_5.0.20-106931-Ubuntu-xenial_amd64.deb ...
Unpacking virtualbox-5.0 (5.0.20-106931~Ubuntu~xenial) over (5.0.20-106931~Ubuntu~xenial) ...
Setting up virtualbox-5.0 (5.0.20-106931~Ubuntu~xenial) ...
addgroup: The group `vboxusers' already exists as a system group. Exiting.
Stopping VirtualBox kernel modules ...done.
Recompiling VirtualBox kernel modules ...failed!
  (Look at /var/log/vbox-install.log to find out what went wrong)
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for hicolor-icon-theme (0.15-0ubuntu1) ...
Processing triggers for shared-mime-info (1.5-2) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu5) ...
Processing triggers for mime-support (3.59ubuntu1) ...

此日志来自 /var/log/vbox-install.log

make KBUILD_VERBOSE=1 SUBDIRS=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 CONFIG_MODULE_SIG$
arch/x86/Makefile:133: stack-protector enabled but compiler support broken
arch/x86/Makefile:148: CONFIG_X86_X32 enabled but no binutils support
Makefile:670: Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-str$
make[1]: gcc: Command not found
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (       $
echo >&2;                                                       \
echo >&2 "  ERROR: Kernel configuration is invalid.";           \
echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are$
echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it$
echo >&2 ;                                                      \
/bin/false)
mkdir -p /tmp/vbox.0/.tmp_versions ; rm -f /tmp/vbox.0/.tmp_versions/*
make -f ./scripts/Makefile.build obj=/tmp/vbox.0
  gcc -Wp,-MD,/tmp/vbox.0/linux/.SUPDrv-linux.o.d  -nostdinc -isystem   -I./arc$
/bin/sh: 1: gcc: not found
scripts/Makefile.build:258: recipe for target '/tmp/vbox.0/linux/SUPDrv-linux.o$
make[2]: *** [/tmp/vbox.0/linux/SUPDrv-linux.o] Error 127
Makefile:1396: recipe for target '_module_/tmp/vbox.0' failed
make[1]: *** [_module_/tmp/vbox.0] Error 2
Makefile:298: recipe for target 'vboxdrv' failed
make: *** [vboxdrv] Error 2

我无法运行 vagrant box,因为这个 virtualbox “VirtualBox 抱怨内核模块未加载。”

答案1

您应该安装 dkms 和构建工具。dpkg 不会为您安装依赖项,所以我认为使用它来单独安装 debian 软件包不是一个好主意。

有时,使用 apt-get 修复您创建的问题会更简单,它会在您运行 dpk -i 后安装缺少的依赖项。然后,删除并重新安装 virtualbox 5 包:

$ sudo apt-get -f install
$ dpkg -r virtualbox*.deb
$ dpkg -i virtualbox*.deb

默认的 virtualbox 软件包需要很多依赖项。首先,列出您下载的软件包的依赖项,然后使用 apt-get 安装它们:

$ dpkg -I virtualbox*.deb
$ sudo apt-get install dkms linux-header-generic ...

然后,您可以继续安装该包。

$ sudo dpkg -i  virtualbox*.deb

我建议您使用 PPA 而不是使用 dpkg。(https://linuxpropaganda.wordpress.com/2016/07/07/install-virtualbox-from-ppa-in-xubuntu-16-04/

$ wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox_2016.asc -O- | sudo apt-key add -
$ sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" >> /etc/apt/sources.list.d/virtualbox.list' 
$ sudo apt-get update
$ sudo apt-get install virtualbox-5.2

相关内容