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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With