在18.04上安装VMware:无法构建vmmon。

我正在尝试按照https://help.ubuntu.com/community/VMware/Player中的说明安装VMware。

但是我遇到一个错误提示,告诉我要查看一个日志文件,其中包含以下内容:

Extracting the vmmon source from "/usr/lib/vmware/modules/source/vmmon.tar".
Successfully extracted the vmmon source.
Building module with command "/usr/bin/make -j4 -C /tmp/modconfig-GoVdrH/vmmon-only auto-build HEADER_DIR=/lib/modules/4.15.0-22-generic/build/include CC=/usr/bin/gcc IS_GCC_3=no"
Failed to build vmmon.  Failed to execute the build command.

为了准确找出问题所在,我在命令行上运行了vmware-modconfig --console --install-all,它显示了以下错误信息:
./arch/x86/include/asm/processor-flags.h:39:0: note: this is the location of the previous definition
 #define CR3_PCID_MASK 0xFFFull

                      ^
/tmp/modconfig-3S1CBa/vmmon-only/linux/driver.c:256:12: error: ‘struct timer_list’ has no member named ‘data’
    tscTimer.data     = 0;
    unsigned int lockedPages = global_page_state(NR_PAGETABLE) +
                               ^~~~~~~~~~~~~~~~~
                               global_numa_state
/tmp/modconfig-3S1CBa/vmmon-only/linux/driver.c: In function ‘init_module’:
/tmp/modconfig-3S1CBa/vmmon-only/linux/driver.c:338:4: error: implicit declaration of function ‘init_timer’; did you mean ‘init_timers’? [-Werror=implicit-function-declaration]
    init_timer(&tscTimer);
    ^~~~~~~~~~
    init_timers
/tmp/modconfig-3S1CBa/vmmon-only/linux/hostif.c: In function ‘HostIF_InitUptime’:
    init_timers
/tmp/modconfig-3S1CBa/vmmon-only/linux/hostif.c:1754:31: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
    uptimeState.timer.function = HostIFUptimeResyncMono;
 LinuxDriverSyncReadTSCs(uint64 *delta) // OUT: TSC max - TSC min
 ^~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
cc1: some warnings being treated as errors
scripts/Makefile.build:332: recipe for target '/tmp/modconfig-3S1CBa/vmmon-only/linux/hostif.o' failed
make[2]: *** [/tmp/modconfig-3S1CBa/vmmon-only/linux/hostif.o] Error 1
Makefile:110: recipe for target 'vmmon.ko' failed
make: *** [vmmon.ko] Error 2

如何修复这个问题,或者让隐式函数声明和不兼容的指针类型不被视为错误?还有没有更简单的方法在18.04上安装最新的VMware?
注意:与VMWare Workstation Pro 12 on Ubuntu 16.04 cannot compile vmmon不同的错误。

你可以尝试这里的解决方案:这里 - ptetteh227
3个回答

我找到了一个解决方案,并根据mkucebek的github源代码创建了一个脚本文件。
你需要创建一个包含这个内容的文件,并在每次需要时运行它(通常是在安装新内核时)。
#!/bin/bash
VMWARE_VERSION=workstation-12.5.9
TMP_FOLDER=/tmp/patch-vmware
rm -fdr $TMP_FOLDER
mkdir -p $TMP_FOLDER
cd $TMP_FOLDER
git clone https://github.com/mkubecek/vmware-host-modules.git
cd $TMP_FOLDER/vmware-host-modules
git checkout $VMWARE_VERSION
git fetch
make
sudo make install
sudo rm /usr/lib/vmware/lib/libz.so.1/libz.so.1
sudo ln -s /lib/x86_64-linux-gnu/libz.so.1 
/usr/lib/vmware/lib/libz.so.1/libz.so.1
sudo /etc/init.d/vmware restart

然后,您只需启动VMware Workstation而无需构建模块。

嗨Charly,欢迎来到askubuntu!请在你的下一篇帖子中添加链接。 - abu_bua
版本不匹配,与vmmon模块预期的329.0不符,而是309.0。 您的'vmmon'内核模块版本不正确。 请尝试重新安装VMware Workstation。 - altagir
1这个解决方案在我使用的Ubuntu 19.04和Workstation 15.0.4上完美运行。 - Lukas Bradley
我遇到了与“VMware Workstation 15.0.4”相同的问题,通过编译和安装“vmware-host-modules”解决了。如果你使用的是其他版本的VMWare,请使用git branch -a找到适当的版本,并使用git checkout切换。对于我来说,不需要删除和链接libz.so.1并重新启动vmware服务。 - soroosh

安装最新版本14.1.2。该错误已修复。请点击这里查看。下载链接在这里

#!/bin/bash
VMWARE_VERSION=`vmware-installer -l |grep workstat|awk '{print $2}' |awk 'BEGIN {FS="."}{print "workstation-"$1"."$2"."$3}'`
echo $VMWARE_VERSION
TMP_FOLDER=/tmp/patch-vmware
rm -fdr $TMP_FOLDER
mkdir -p $TMP_FOLDER
cd $TMP_FOLDER
git clone https://github.com/mkubecek/vmware-host-modules.git
cd $TMP_FOLDER/vmware-host-modules
git checkout $VMWARE_VERSION
git fetch
make
sudo make install
sudo rm /usr/lib/vmware/lib/libz.so.1/libz.so.1
sudo ln -s /lib/x86_64-linux-gnu/libz.so.1 
/usr/lib/vmware/lib/libz.so.1/libz.so.1
sudo /etc/init.d/vmware restart

这在我的 Fedora 30 和 Workstation 15.1.0 上工作。


1你能否添加一些关于脚本的操作和方式的细节? - Simon Sudler
这是与上面显示的脚本相同的版本,但可以“检测”已安装的VMware Workstation版本。 - Raul Peñaloza
曾在openSuSE Tumbleweed工作过。 - blissini