ubuntu – 无法在3.8内核上编译Vagrant VirtualBox Guest Additions

前端之家收集整理的这篇文章主要介绍了ubuntu – 无法在3.8内核上编译Vagrant VirtualBox Guest Additions前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
使用VirtualBox 4.3.4和Vagrant 1.3.5.运行带有3.8内核的Ubuntu 12.04.3盒子:
# uname -a
Linux precise64 3.8.0-34-generic #49~precise1-Ubuntu SMP Wed Nov 13 18:05:00 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

尝试编译客户添加失败:

# /etc/init.d/vBoxadd setup
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.

该日志指向缺少的version.h文件

# cat /var/log/vBoxadd-install.log
grep: /lib/modules/3.8.0-34-generic/build/include/linux/version.h: No such file or directory
make KBUILD_VERBOSE=1 CONFIG_MODULE_SIG= -C /lib/modules/3.8.0-34-generic/build SUBDIRS=/tmp/vBox.0 SRCROOT=/tmp/vBox.0 modules
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 missing.";\
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/.VBoxGuest-linux.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/include  -I/usr/src/linux-headers-3.8.0-34-generic/arch/x86/include -Iarch/x86/include/generated  -Iinclude -I/usr/src/linux-headers-3.8.0-34-generic/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/usr/src/linux-headers-3.8.0-34-generic/include/uapi -Iinclude/generated/uapi -include /usr/src/linux-headers-3.8.0-34-generic/include/linux/kconfig.h -Iubuntu/include  -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -O2 -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -Wframe-larger-than=1024 -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO -include /tmp/vBox.0/include/VBox/VBoxGuestMangling.h -I/lib/modules/3.8.0-34-generic/build/include -I/tmp/vBox.0/ -I/tmp/vBox.0/include -I/tmp/vBox.0/r0drv/linux -I/tmp/vBox.0/vBoxguest/ -I/tmp/vBox.0/vBoxguest/include -I/tmp/vBox.0/vBoxguest/r0drv/linux -D__KERNEL__ -DMODULE -DVBox -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 -DIN_MODULE -DRT_WITH_VBox -DVBGL_VBoxGUEST -DVBox_WITH_HGCM -DRT_ARCH_AMD64 -DVBox_WITH_64_BITS_GUESTS  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(VBoxGuest_linux)"  -D"KBUILD_MODNAME=KBUILD_STR(vBoxguest)" -c -o /tmp/vBox.0/.tmp_VBoxGuest-linux.o    /tmp/vBox.0/VBoxGuest-linux.c
/tmp/vBox.0/VBoxGuest-linux.c:199:49: error: expected ‘=’,‘,’,‘;’,‘asm’ or ‘__attribute__’ before ‘g_VBoxGuestPciId’
/tmp/vBox.0/VBoxGuest-linux.c:328:21: error: ‘g_VBoxGuestPciId’ undeclared here (not in a function)
/tmp/vBox.0/VBoxGuest-linux.c:209:1: error: ‘__mod_pci_device_table’ aliased to undefined     symbol ‘g_VBoxGuestPciId’
make[2]: *** [/tmp/vBox.0/VBoxGuest-linux.o] Error 1
make[1]: *** [_module_/tmp/vBox.0] Error 2
make: *** [vBoxguest] Error 2
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.
这对我有用:
vagrant plugin install vagrant-vbguest

完整输出如下:

$vagrant plugin install vagrant-vbguest
$vagrant up
Bringing machine 'default' up with 'virtualBox' provider...
[default] Clearing any prevIoUsly set forwarded ports...
[default] Creating shared folders Metadata...
[default] Clearing any prevIoUsly set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
GuestAdditions versions on your host (4.3.4) and guest (4.2.0) do not match.
stdin: is not a tty
Reading package lists...
Building dependency tree...
Reading state information...
linux-headers-3.8.0-34-generic is already the newest version.
The following NEW packages will be installed:
  dkms
0 upgraded,1 newly installed,0 to remove and 0 not upgraded.
Need to get 73.2 kB of archives.
After this operation,348 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main dkms all 2.2.0.3-  1ubuntu3.1 [73.2 kB]
dpkg-preconfigure: unable to re-open stdin: No such file or directory
Fetched 73.2 kB in 0s (145 kB/s)
Selecting prevIoUsly unselected package dkms.
(Reading database ... 84686 files and directories currently installed.)
Unpacking dkms (from .../dkms_2.2.0.3-1ubuntu3.1_all.deb) ...
Processing triggers for man-db ...
Setting up dkms (2.2.0.3-1ubuntu3.1) ...
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the Box /tmp/VBoxGuestAdditions.iso
stdin: is not a tty
mount: block device /tmp/VBoxGuestAdditions.iso is write-protected,mounting read-only
Installing VirtualBox Guest Additions 4.3.4 - guest version is 4.2.0
stdin: is not a tty
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.4 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.2.0 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
Starting the VirtualBox Guest Additions ...done.
Installing the Window System drivers ...fail!
(Could not find the X.Org or XFree86 Window System.)
An error occurred during installation of VirtualBox Guest Additions 4.3.4. Some     functionality may not work as intended.
stdin: is not a tty
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Setting hostname...
[default] Mounting shared folders...
[default] -- /vagrant
原文链接:https://www.f2er.com/ubuntu/347203.html

猜你在找的Ubuntu相关文章