Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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; } 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.

like image 226
G3yost Avatar asked Apr 07 '18 08:04

G3yost


Video Answer


1 Answers

You need to install 32bit libraries, e.g.

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.

like image 177
Xypron Avatar answered Sep 21 '22 13:09

Xypron