尝试(并且失败)在Windows 10上的64位Ubuntu上运行Hello World 32位C++程序

Man*_*rot 5 c++ ubuntu 32bit-64bit windows-subsystem-for-linux

我通过以下方式从头开始在Windows 10上配置我的新Ubuntu:

# apt-get update
# apt-get install build-essential
# # Am able to compile now using "g++ -Wall -o Hello-World Hello-World.cpp", the binary is working.

# # To check versions, and that both packages were indeed installed
# gcc -v
    # make -v

# apt-get install g++-multilib
# # This also installs gcc-multilib as a dependency
# # Now able to compile using "g++ -m32 -Wall -o Hello-World Hello-World.cpp
# # However the binary Hello-World can't be run. Error message "bash: ./Hello-World: cannot execute binary file: Exec format error

# apt-get install lib32gcc1 lib32stdc++6
# # Those two packages are at this time already both installed and well

# dpkg --add-architecture i386
# apt-get update
# apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
# # Still getting the same error when wanting to ./Hello-World
Run Code Online (Sandbox Code Playgroud)

我想我仍然错过了一个xyz:i386 library,我自己也无法弄清楚哪一个仍然缺失.此外,我不确定这是否是"Windows上的Ubuntu"特定的东西,或者如果在普通的Ubuntu 64位操作系统上以同样的方式进行此操作也会发生这种情况.你有什么建议吗?

完成后,这是Hello-World.cpp文件的内容:

#include <iostream>

using namespace std;

int main (int argc, char **argv)

{

    cout << "Hellobaby" << endl;

return 0;
}
Run Code Online (Sandbox Code Playgroud)

Man*_*rot 1

在我看来,Sam Varshavchik 是对的,Windows 上的 Ubuntu 目前不支持 32 位架构程序。我在 VirtualBox 上安装了虚拟 Ubuntu 64 位,并且使用与我最初的帖子中描述的完全相同的命令,程序编译并运行。

谢谢大家的评论