简体   繁体   English

在64位Debian上无法运行32位二进制文​​件

[英]Can't run 32 bit binary on 64 bit Debian

I'm compiling C++ on Debian Linux (64 bit) and need to be able to compile to 32 bit for another system. 我正在Debian Linux(64位)上编译C ++,并且需要能够为另一个系统编译为32位。 The binaries won't run on my 64 bit system and having them run there would be far more convenient for testing. 二进制文件不能在我的64位系统上运行,让它们在那里运行会更方便测试。

My C++ for testing this is int main () { std::cout << "This is Main.cpp" << std::endl; } 我测试它的C ++是int main () { std::cout << "This is Main.cpp" << std::endl; } int main () { std::cout << "This is Main.cpp" << std::endl; } with iostream included, so nothing fancy there. int main () { std::cout << "This is Main.cpp" << std::endl; }用的iostream包括在内,所以没有什么花哨那里。

My compile line is g++ -m32 Main.cpp 我的编译行是g++ -m32 Main.cpp

When I do ./a.out I get -bash: ./a.out: cannot execute binary file: Exec format error 当我这样做./a.out我得到-bash: ./a.out: cannot execute binary file: Exec format error

I have done quite a bit of searching trying to resolve this and have apt installed: libc6:i386, libncurses5:i386, and libstdc++6:i386. 我已经做了很多搜索试图解决这个并安装了apt:libc6:i386,libncurses5:i386和libstdc ++ 6:i386。

Any other ideas to fix this would be much appreciated. 任何其他想法来解决这个问题将非常感激。

You need to install 32bit libraries, eg 您需要安装32位库,例如

dpkg --add-architecture i386
apt-get update
apt-get install libc6-i386

You can find out which libraries are needed using the ldd command. 您可以使用ldd命令找出所需的库。 You can use apt-file to find the packages for the libraries. 您可以使用apt-file查找库的包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM