@zifehng
2018-04-06T19:12:36.000000Z
字数 1973
阅读 1949
Ubuntu
VirtualBox
软件环境:
Ubuntu16.04
VirtualBox5.1.34
安装VirtualBox在打开虚拟机时出现如下错误提示:
先按照提示用root权限执行modprobe vboxdrv
重新加载模块,却又提示无法找到vboxdrv模块,
于是尝试重新安装软件包virtualbox-dkms:
$ sudo apt install --reinstall virtualbox-dkms
...
Error! Bad return status for module build on kernel: 4.13.0-38-generic (x86_64)
Consult /var/lib/dkms/virtualbox/5.1.34/build/make.log for more information.
...
软件包安装失败,打开make.log,查看更详细的错误信息:
DKMS make.log for virtualbox-5.1.34 for kernel 4.13.0-38-generic (x86_64)
Fri Apr 6 12:53:19 CST 2018
make: Entering directory '/usr/src/linux-headers-4.13.0-38-generic'
AR /var/lib/dkms/virtualbox/5.1.34/build/built-in.o
AR /var/lib/dkms/virtualbox/5.1.34/build/vboxdrv/built-in.o
CC [M] /var/lib/dkms/virtualbox/5.1.34/build/vboxdrv/linux/SUPDrv-linux.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
scripts/Makefile.build:308: recipe for target '/var/lib/dkms/virtualbox/5.1.34/build/vboxdrv/linux/SUPDrv-linux.o' failed
make[2]: *** [/var/lib/dkms/virtualbox/5.1.34/build/vboxdrv/linux/SUPDrv-linux.o] Error 1
scripts/Makefile.build:581: recipe for target '/var/lib/dkms/virtualbox/5.1.34/build/vboxdrv' failed
make[1]: *** [/var/lib/dkms/virtualbox/5.1.34/build/vboxdrv] Error 2
Makefile:1550: recipe for target '_module_/var/lib/dkms/virtualbox/5.1.34/build' failed
make: *** [_module_/var/lib/dkms/virtualbox/5.1.34/build] Error 2
make: Leaving directory '/usr/src/linux-headers-4.13.0-38-generic'
原来是编译工具gcc出现了问题,联想到之前为了编译Android5.1代码,降级安装了gcc-4.8,而Ubuntu16.04自带的版本为gcc-5,很有可能这就是原因所在,于是尝试恢复gcc-5版本:
$ sudo update-alternatives --install gcc /usr/bin/gcc /usr/bin/gcc-5 90
$ sudo update-alternatives --install g++ /usr/bin/gcc /usr/bin/g++-5 90
$ sudo update-alternatives --install gcc /usr/bin/gcc /usr/bin/gcc-4.8 100
$ sudo update-alternatives --install g++ /usr/bin/gcc /usr/bin/g++-4.8 100
$ sudo update-alternatives --config gcc
$ sudo update-alternatives --config g++
再次执行:
$ sudo apt install --reinstall virtualbox-dkms
$ sudo modprobe vboxdrv
然后打开VirtualBox加载虚拟机,顺利解决!