compiling windows apps on linux

now that we successfully used cmake to compile a linux app (in the last article), we will now try and compile it for windows.

I am doing this on Gentoo linux, so your mileage may vary if you used a different distribution.

I am starting with http://gentoo-wiki.com/HOWTO_MinGW as a rough guide.

  • # emerge -va sys-devel/crossdev
  • # echo ‘PORTDIR_OVERLAY=”/usr/i686-mingw32/usr/portage /usr/local/portage $PORTDIR_OVERLAY”‘ >> /etc/make.conf
  • create the directory /usr/i686-mingw32/usr/portage
  • install the toolchain: # crossdev i686-mingw32

With Ubuntu/Debian you can simply install it using apt: “apt-get install mingw32”. This will install the toolchain as i586-mingw32msvc-gcc to /usr/bin/ .emerge the packages you want to have as cross compiled programs or libraries.

Once you have installed ming32, it is easy to compile for linux:

#  i686-mingw32-gcc helloworld.cpp -o wintest.exe

Now the next step in the puxxle is to get cmake to compile for both OSes  each time make is run.

About Andy Dingfelder

Andy is a Technology Manager with over 20 years of experience in Software Development, Project Management and Team Management in Telco, Healthcare and General SDLC. Full bio is available at: http://www.linkedin.com/in/dingfelder Follow at http://twitter.com/dingfelder Andy Dingfelder lives in Hawkes Bay, New Zealand with his wife and two daughters.
This entry was posted in C++, CDT, cmake, gentoo, linux, windows. Bookmark the permalink.