我通过以下方式在 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 library
,我只是无法自己弄清楚哪个仍然缺少。此外,我不确定这是否是“Windows 上的 Ubuntu”特定的事情,或者在普通的 Ubuntu 64 位操作系统上以相同方式进行时是否也会发生这种情况。你有什么建议吗?
为了完成,这是Hello-World.cpp
文件的内容:
#include <iostream>
using namespace std;
int main (int argc, char **argv)
{
cout << "Hellobaby" << endl;
return 0;
}