Error building main Guest Additions Module while installing VirtualBox guest additions

I have installed Ubuntu 12.10 Guest on Ubuntu 12.04 Host using VirtualBox. Everything is from repository and no direct install. When I install the guest additions, the below error is shown in the console. Before running the command I mapped the VBoxGuestAdditions.iso in the Guest.

The closest I could get is this article which says to install the latest version of VirtualBox (not the one from the repository). Is there any alternate solution?

sudo ./VBoxLinuxAdditions.run

Verifying archive integrity... All good.  
Uncompressing VirtualBox 4.1.12 Guest Additions for Linux.........  
VirtualBox Guest Additions installer  
Removing installed version 4.1.12 of VirtualBox Guest Additions...  
Removing existing VirtualBox DKMS kernel modules ...done.  
Removing existing VirtualBox non-DKMS kernel modules ...done.  
Building the VirtualBox Guest Additions kernel modules  
The headers for the current running kernel were not found. If the following  
module compilation fails then this could be the reason.

Building the main Guest Additions module ...fail!  
(Look at /var/log/vboxadd-install.log to find out what went wrong)  
Doing non-kernel setup of the Guest Additions ...done.  
Installing the Window System drivers  
Warning: unknown version of the X Window System installed.  Not installing  
X Window System drivers.  
Installing modules ...done.  
Installing graphics libraries and desktop services components ...done.

Solution 1:

For VirtualBox version 4.2.0 . Oracle's Version.

Install the package virtualbox-guest-x11 and you will be fine.

enter image description here

From terminal (Virtual System)

sudo apt-get install virtualbox-guest-x11

Reboot you Virtual System.

Solution 2:

I received the dreaded "The headers for the current running kernel were not found" even though "Complete Generic Linux Kernel and Headers" were installed (Ubuntu 12.10 running under VirtualBox on a Windows Server 2003/Q6600). So I checked out this page...

For clarity's sake, the precise command for you copy-pasters out there (which would include me, hence I found out that a little clarification was in order) is:

sudo apt-get install build-essential linux-headers-`uname -r` dkms

Which further implies under "Devices" first turn "Shared Clipboard" on to "Bi-Directional" (for ease of use)

Then open a terminal window (click on the top "Dash" button, type "terminal" in the search box, click on the terminal icon to open same)

Then copy/paste the above sudo apt-get command in the terminal window by right-clicking in the terminal window

Then enter your root/admin password when prompted

Then Devices/Install Guest Addition via VirtualBox

And, extraneous to the above sequence but still on the subject of Guest Additions, the latest/greatest can always be downloaded/mounted as a CD from

http://download.virtualbox.org/virtualbox/

Additional info for Ubuntu 12.10 as I subsequently found out I had to

  1. apt-get purge xserver-xorg-video-vmware

  2. reinstall guest additions from the 4.6.2 .iso (available from above URL)

  3. add "vboxvideo" in /etc/modules (I

    sudo gedit /etc/modules
    

    but could

    sudo bash -c 'echo vboxvideo >> /etc/modules' 
    

    )

  4. stop the virtual machine

  5. Settings/Display/Enable 3D acceleration

to get better performance. Now I get:

Not software rendered:    yes
Not blacklisted:          yes
GLX fbconfig:             yes
GLX texture from pixmap:  yes
GL npot or rect textures: yes
GL vertex program:        yes
GL fragment program:      yes
GL vertex buffer object:  yes
GL framebuffer object:    yes
GL version is 1.4+:       yes

as well as some not-so-pleasing OpenGL warnings related to the mesa table from the command

/usr/lib/nux/unity_support_test -p

Solution 3:

  1. Start a terminal and type:

    sudo apt-get install build-essential linux-headers-`uname -r` dkms
    
  2. Then reinstall VirtualBox Guest Addition from Devices → Install Guest Addition.

Tested in Windows 7 as host with VirtualBox 2.2.4

Solution 4:

Upgrading to Virtualbox version 4.2.4 using Synaptic Package Manager (Dash Home did not show the new version in the Ubuntu repositories) I still needed to get kernel headers to avoid the 'missing kernel headers' error message and build the guest additions.

sudo apt-get install build-essential kernel-headers-`uname -r`

Note: That is a BACKTIC uname -r NOT a single apostrophe 'uname -r' (On my keyboard the backtic is just to the Left of the number 1).

Solution 5:

Upgraded VirtualBox to the latest version, problem resolved. Guest Additions installation is OK now.