How to make my C++ programs multi-architecture (32-bit and 64-bit)?


Developing an application in native C++ using DevCPP and the MinGW compiler, when running the application on another machine I noticed an architecture error, because my program only runs in 64-bits, how can I make it multi-architecture? That is, to make it run in both 64-bit and 32-bit (without doing a build for each of the architectures)


Standard C++ only generates native code for the architecture on which it will run, so there is no way to run it on a different architecture. The only way is to compile to the appropriate architecture.

Of course, a 32-bit application could run on a 64-bit operating system if it has some compatibility layer. This is the case with Windows and some Linux distributions. The opposite is not technically feasible even if someone wanted to do it, except for complex emulation and the result will be horrible.

Just compiling for another architecture may not be enough. The code needs to be well written to work well on both, the problem may be there.

Technically it would be possible to have a feature like C# (non-native code), but nobody bothered to do that because it doesn't make much sense.

Scroll to Top