Compiling for both x86 and x64 Compiling for both x86 and x64 windows windows

Compiling for both x86 and x64


x86 executable is fully supported on x64 host. E.g. any EXE you compile in 32-bit mode will run without any problems on 32-bit and 64-bit host. If you don't know why you need 64-bit executable, you probably don't, so 32-bit executable alone will suffice.

However, with DLLs it is a different matter. The DLL's architecture (32-bit or 64-bit) must match the executable where the DLL is going to be used. E.g. if you're writing an Explorer extension for x64 Windows, explorer.exe is going to be 64-bit, so your DLL must also be 64-bit, otherwise it cannot be loaded.

There is no way to combine two different architectures into one DLL or EXE on Windows. So you're going to need two DLLs if you need to support both 32-bit and 64-bit hosts.