无法在wsl子系统下正确运行csapp实验1datalab的实验程序

按照手册指引
make 然后 ./fshow 然后就

cannot execute binary file: Exec format error

发现所有可执行文件均无法执行,搜索一下该错误,多与在32位系统下运行64位程序有关。
然而本机与系统均是64位,可能需要安装相关支持。
搜索ubuntu18.04安装32位支持环境安装相关依赖,无效
考虑wsl的问题。
解决方案转载自https://blog.csdn.net/shengerjianku/article/details/82290482

Edit: requires "Fall Creators Update", 1709, build 16299 or newer (I think)

Presuming a fresh Ubuntu WSL instance, you'll need to install the qemu-user-static package, add the i386 >binfmt, enable the i386 architecture, update your package lists, and install some i386 packages:

Install qemu and binfmt

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'

[Edit: whoops, need to update package lists, added sudo apt update]

This will activate i386 support by causing them to be executed through qemu-i386-static, and drop a config file into /var/lib/binfmts/ for future reactivation.

You will need to reactivate this every time you restart WSL and want i386 support:

sudo service binfmt-support start

Enable i386 architecture and packages

sudo dpkg --add-architecture i386
sudo apt update
sudo apt install gcc:i386 /*wrong in my wsl but can still run programs correctly*/

你可能感兴趣的:(无法在wsl子系统下正确运行csapp实验1datalab的实验程序)