我是在windows下安装的VirtualBox(简称Vbox),并且顺利的在Vbox上安装了fedora(Linux)。因为在没有安装增强插件时,虚拟机的分辨率是无法调整的,很难看。所以我就在Vbox点击了那个安装增强插件的选项。但是总是安装到一半失败。
失败现象:
在按下那个选项的时候,虚拟机中的Linux会挂载一个光驱,然后我们可以从光驱中找到适合的安装脚本,然后执行那个脚本安装。注意要使用sudo,还有看准脚本,虽然不符合的话脚本也执行不了。
如果就这么执行能成功,就没必要写这个了。
失败原因:
1 | =========================== |
2 | Please install the build and header files for your current Linux kernel. |
3 | The current kernel version is 2.6.31.5-127.fc12.i686 |
4 | Please install the GNU compiler. |
5 | Problems were found which would prevent the Guest Additions from installing. |
6 | Please correct these problems and try again. |
7 |
8 | ============================ |
我们可以在这个输出中看到,有gcc,build的字样。这说明安装中有使用gcc进行编译。
通常情况,编译失败都是因为所需的开发包未安装。
如何解决:
知道原因,那就好办了,没有包,安装呗。
我们需要安装这三个包: gcc kernel-devel kernel-header
yum走起就行。
1 | sudo yum install gcc kernel-devel kernel-header |
有的时候,并不是gcc没安装,而是g++没安装,g++编译的是c++,属于gcc扩展。要这么安装:
1 | sudo yum install gcc-c++ |
还有问题:
通常情况,你已经可以安装扩展插件了。但是还有一些人会提示失败。
1 | ============================ |
2 | Please install the build and header files for your current Linux kernel. |
3 | The current kernel version is 2.6.31.5-127.fc12.i686 |
4 | Problems were found which would prevent the Guest Additions from installing. |
5 | Please correct these problems and try again. |
6 | ============================= |
这个错误的原因是几个软件包的版本高于内核的版本,所以我们需要升级内核。
1 | sudo yum update |
这样就没有问题了。
如果还有问题,请留言讨论。