分享

解决win10 WSL下cannot execute binary file: Exec format error

 logicsoft 2023-11-02 发布于浙江

主要原因是不支持32位程序,可以用如下方法启用:
WSL默认使用64bit的程序,不支持32位的程序,但我们仍然可以使用QEMU来虚拟化内核。
安装QEMU

sudo apt update
sudo apt install qemu-user-static
sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'
  • 1
  • 2
  • 3

启动服务,注意每次调试32位程序之前都要启用一次

sudo service binfmt-support start
  • 1

启用32位架构

sudo dpkg --add-architecture i386
sudo apt update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

  • 1
  • 2
  • 3
  • 4

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多