How to Build and Install wxPython for Microsoft Windows under Cygwin


This procedure produces a version of wxPython that works
with the Cygwin build of Python 2.5 (using the Cygwin C
runtime library) and uses native Windows graphics (i.e., direct GDI
calls, not X Window calls). This combination is intended to work with a
Cygwin version of GNU Radio (one that also uses the Cygwin C runtime

These instructions are current as of September 2009 and assume you
are using wxPython
and current versions of all Cygwin tools and libraries. They will
probably work with later releases as well, but this remains to be

Step-by-Step Instructions.

Feel free to modify this recipe to suit your preferences:

(1) Download the wxWidgets and wxPython source code from the wxPython-src link at to /usr/src.

(2) Unpack the source distribution:
cd /usr/src
tar -jxf wxPython-src-

This will create the directory /usr/src/wxPython-src- For
convenience (especially if you want to put your code somewhere
else) I will call this directory $WXDIR in what follows. To make
the commands work as written, run the command
export WXDIR=/usr/src/wxPython-src-
(3) Create a build directory:
mkdir build-local

Choose any name for your build directory; I use build-local
here. (4) Configure wxWidgets:
cd $WXDIR/build-local
../configure --with-msw

(4a) Apply patches:

These instructions apply to release They may or may not be needed in
later versions.

Download wxPython- to $WXDIR using the Original Format link
at the bottom of the page.
Apply the patches with
patch -p0 -b -i wxPython-
You will also need to find the file
and after the line:

add the line:
(5) Compile and link wxWidgets:
cd $WXDIR/build-local
make -C contrib/src/stc

You may do make -C contrib/src/gizmos to compile and link the gizmos package.
The gizmos package has some fun tools for developing Python programs but is not required for GNU Radio. (6) Install wxWidgets:
cd $WXDIR/build-local
make install
make -C contrib/src/stc install

This installs the wxWidgets DLLs in /usr/local/lib.
If you compiled the gizmos package, install it with make -C contrib/src/gizmos install. Depending on how you installed Cygwin, you might get an error like
/usr/bin/install -c -d /usr/local/lib
/usr/bin/install: cannot change permissions of @/usr/local/lib': Permission denied

You can fix this by changing /usr/local/lib and /usr/local/bin to give you ownership of these directories. See the instructions in
hints tips known problems and solutions for Windows. (7) Move the DLLs to /usr/local/bin:
mv /usr/local/lib/cygwx*.dll /usr/local/bin

Unless /usr/local/lib is in your PATH, it is easier to have the
DLLs in /usr/local/bin. (If you know how to make the
configure/build process do this for you, please let me know.) (8) Test the build and installation of wxWidgets:
cd $WXDIR/build-local/samples/minimal

This should produce an empty window to prove that wxWidgets works. (9) Build wxPython:
cd $WXDIR/wxPython
python build_ext --inplace WXPORT=msw COMPILER=cygwin BUILD_GLCANVAS=0 BUILD_GIZMOS=0 UNICODE=0

This builds the Python connection to wxWidgets. If you built gizmos you should omit the BUILD_GIZMOS=0 flag. (10) Install wxPython:
cd $WXDIR/wxPython

This installs wxPython. If you build gizmos you should omit the BUILD_GIZMOS=0 flag. (11) Test your wxPython installation:
cd $WXDIR/wxPython/demo

This should present you with a green snake (and a window showing what wxPython can do). If this works, you are done. You should now be able to "import wx", build gr-wxgui, and "import wxgui".

If doesn't work your version of Cygwin may be out of date (see hints tips known problems and solutions for Windows).


  • The patch in statbmp.patch is not needed with wxPython or later
  • The patches in config.patch and treelistctrl.cpp.patch are not needed with wxPython

statbmp.patch - statbmp patch for wxWidgets on Cygwin (1.5 KB) Don Ward, 08/26/2006 01:04 AM

config.patch - patch file for wxPython on Cygwin (597 Bytes) Don Ward, 08/26/2006 01:25 AM

treelistctrl.cpp.patch - patch for gizmos/wxCode/src/treelistctrl.cpp for wxPython (430 Bytes) Redmine Admin, 12/31/2006 09:58 PM

wxPython- - patches for wxPython- (1.5 KB) Redmine Admin, 09/24/2009 05:46 PM

注:How to Build and Install wxPython for Microsoft Windows under Cygwin(原文出处,翻译整理仅供参考!