Cross Compiling C/C++ for Windows on Linux

Why should I cross compile? I myself asked this question. The context here is, I have to write an encryption program in C which will be used on both Windows and Linux. The program will encrypt a text in Windows and decrypt the same on Linux. My program is pretty small and it can be easily compiled on two machines, one with Windows and one with Linux. But I want to learn how to cross compile for Windows on Linux. Now coming to the question, I got some reasons for cross compiling here. To the large extent that is true but will not applicable in my case. In this post I will explain how to cross compile a simple C program using MingW toolchain for Windows on Linux. I am using Ubuntu here but it is same for other distros as well. In later articles I will show how to cross compile a library and link it as I did for my encryption program