VirtualBox is a great free, open source virtualization platform from Sun Microsystems (well, now Oracle). After installing an operating system in VirtualBox, there is an add-on product that can be installed inside of the guest operating system called Guest Additions that enables a more integrated experience between the host and guest operating systems as well as improves performance in the guest operating system. In most Windows and Linux operating systems, this is a simple install that already has all of the prerequisites needed to install Guest Additions.
However, in a standard CentOS installation, this is not the case as it is missing a few dependencies needed by the Guest Additions installer. Unfortunately, the error given by the Guest Additions installer only tells you what is missing, but not what package(s) you need to install that will satisfy the dependencies needed.
Fortunately, it’s a pretty easy fix. All you need to do is install a few packages using yum and you’re set to go.
Run the following command as root to install the dependencies needed by Guest Additions.
yum install gcc-c++
yum install kernel-headers
yum install kernel-devel
Of course, you could always combine these into one command by running:
yum install gcc-c++ kernel-headers kernel-devel
Once this has finished, it is best to go ahead and restart CentOS to ensure that the latest kernel headers are loaded. After restarting, you should be able to run the install for Guest Additions without a problem.