简体   繁体   中英

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. The binaries won't run on my 64 bit system and having them run there would be far more convenient for testing.

My C++ for testing this is 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.

My compile line is g++ -m32 Main.cpp

When I do ./a.out I get -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.

Any other ideas to fix this would be much appreciated.

You need to install 32bit libraries, eg

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

You can find out which libraries are needed using the ldd command. You can use apt-file to find the packages for the libraries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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