gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:43:16 26 4
gpt4 key购买 nike

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

关于c++ - 尝试(但失败)在 Windows 10 的 64 位 Ubuntu 上运行 Hello World 32 位 C++ 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36665669/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com