(C/C++) How to make windows executable file(.exe) from GNU/Linux


To make windows executable file(.exe) from GNU/Linux you need a Cross-Compiler named ” mingw32

  • Installation

If you using Ubuntu  then install “mingw32".You can install it many ways but if you are lazy as like me then you can use terminal.Give this command on terminal.

sudo  apt-get  install  mingw32

Replace “apt-get” with “yum” or whatever your linux distro uses.

 

To compile C  source code give below command on terminal

i586-mingw32msvc-cc  main.c  -o  main.exe

here main.c is your c source file and main.exe is you desire .exe file name.

To compile C ++  source code give below command on terminal

i586-mingw32msvc-c++  clock.cpp  -o  clock.exe

here clock.cpp  is your c++ source file and clock.exe is you desire .exe file name.

Now you can run those main.exe and clock.exe on Windows OS. if you want to run those .exe file on linux you need wine or  other software that can run windows executable file. I prefer to use wine its  free.

to install wine on Ubuntu give this command on terminal

sudo  apt-get  install  wine

Replace “apt-get” with “yum” or whatever your linux distro uses.

now type on terminal

wine  main.exe

 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s