Sunday, June 28, 2009

Compiling win32 binaries on linux

Old habits are hard to be dropped.

As a long term linux user I fell much more comfortable using my old emacs text editor with a good old "green on black" Xterm terminal console window.

So we have some legacy code here on my current job, those which must run also on windows. I was making some improvements on it, porting to use wx-widgets, compiling and using it on linux. But some windows users started to want those improvements on their widows versions. As the only WX programmer around, I was the only person able to compile the windows version. As I think future improvements would also be wanted by the windows users, I decided to deploy a windows wxDevCPP installation on wine on my linux workstation.

Well the first steps are simple:
  1. First get a wx-DevCPP installation executable on
  2. Install it using wine
  3. Open your .dev files on wxDev
  4. Build it
Now you have a, which can be used to directly compile win32 binaries.
A batch file could also be written to make things easy:
@echo off
set PATH=%PATH%;C:\Program Files\Dev-Cpp\bin
c:\Program Files\Dev-Cpp\bin\mingw32-make -f clean
c:\Program Files\Dev-Cpp\bin\mingw32-make -f

The command "wine cmd" can be used to enter on a windows command line console. In this console one just need to call the batch file (compile.bat).
A special win tag can be added to the linux Makefile, so one can use a make win directly from the linux console:
wineconsole --backend=curses compile.bat
And that is it, now to build a linux binary one just need to type make, and for a windows binary, make win.
This procedure is suitable for small projects, I haven't tested with big projects.

No comments:

Post a Comment