加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

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

发布时间:2020-12-14 02:51:23 所属栏目:Windows 来源:网络整理
导读:我通过以下方式从头开始在 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
我通过以下方式从头开始在 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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读