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

我通过以下方式从头开始在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

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

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

#include <iostream>

using namespace std;

int main (int argc, char **argv)

{

    cout << "Hellobaby" << endl;

return 0;
}
最佳答案
我认为你没有安装所有g相关的依赖项.执行以下提到的用于安装依赖项的命令.

sudo apt-get install g++

enter image description here

enter image description here

转载注明原文:尝试(并且失败)在Windows 10上的64位Ubuntu上运行Hello World 32位C程序 - 代码日志