问题

Ubuntu 20.04下启动虚拟机VMware时,报错:Before you can run VMware several modules must be compiled and loaded into the running kernel. 按提示点击install无法解决。

解决办法

1 下载vmware-host-modules并切换到对应分支

git clone https://github.com/mkubecek/vmware-host-modules
cd vmware-host-modules
git checkout workstation-16.1.2 #这里16.1.2替换为你的VM版本

这里如果直接执行sudo make & sudo make install会报以下错误:

   67 |    ASSERT_ON_COMPILE(sizeof(Selector) == 2 &&                                \
      |                      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |                      ((__builtin_constant_p(expr) && ((expr) >> 16) == 0) || \
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                       sizeof(expr) <= 2))
      |                       ~~~~~~~~~~~~~~~~~~    

2. 编辑vm_asm_x86.h

编辑vmware-host-modules/vmmon-only/include/vm_asm_x86.h
将第65行附近的以下内容:

#ifndef USE_UBSAN
#define ASSERT_ON_COMPILE_SELECTOR_SIZE(expr)                                \
   ASSERT_ON_COMPILE(sizeof(Selector) == 2 &&                                \
                     ((__builtin_constant_p(expr) && ((expr) >> 16) == 0) || \
                      sizeof(expr) <= 2))
#else
#define ASSERT_ON_COMPILE_SELECTOR_SIZE(expr)
#endif

修改为(注释其它,只保留#define ASSERT_ON_COMPILE_SELECTOR_SIZE(expr)这一行):

// #ifndef USE_UBSAN
// #define ASSERT_ON_COMPILE_SELECTOR_SIZE(expr)                                \
//    ASSERT_ON_COMPILE(sizeof(Selector) == 2 &&                                \
//                      ((__builtin_constant_p(expr) && ((expr) >> 16) == 0) || \
//                       sizeof(expr) <= 2))
// #else
#define ASSERT_ON_COMPILE_SELECTOR_SIZE(expr)
// #endif

3. make & make install

然后再执行:

sudo make
sudo make install

最后,便可成功启动VM.

参考链接:

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐