【发布时间】:2016-08-08 12:28:40
【问题描述】:
我通过以下方式在 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;
}
【问题讨论】:
-
什么是“Windows 10 上的 ubuntu?”
-
@SamVarshavchik 这是 windows 10 中的新 linux 子系统,它基本上是 windows 10 上的 bash(目前仅在内部构建中)
-
Windows 10 正在获得 Bash 环境。 Fast Ring-Insider Program 的每个人现在都可以测试它。 msdn.microsoft.com/en-us/commandline/wsl/about
-
在我看来,64 位 Windows 环境不支持加载 32 位可执行文件。要么,要么 gcc 没有发出正确的二进制文件。再多安装额外的库也无济于事。此错误似乎是加载错误,而不是与解析未定义的库引用相关的错误。
标签: c++ ubuntu 32bit-64bit windows-subsystem-for-linux