Building wxWidgets using mingw32 on Ubuntu Linux

Now for something entirely new for my blog. I am going to mix some business in with the religion and the politics. How’s that for innovation? I thought you’d like it!

In my work I have to maintain an application in several operating systems. The two main OS’s which we use are Linux and Windows. My work group has standardized around Ubuntu linux due to it’s ease of use and it’s incredible support for our hardware {sound, graphics, and network included}.

I am the developer responsible for supporting and upgrading the DSP microcode debugger application. This application is Debugger like Visual Studios C++ debugger. It allows the developer to debug, in real time, the microcode by single stepping, setting breakpoints, examining register contents and memory dumps.

DSP Microcode Debugger

DSP Microcode Debugger

Many of the users prefer to run the debugger on the Windows platform, although a number of them also run it on the Linux platform. The debugger uses the popular wxWidgets GUI toolkit which provides cross-platform classes which make developing easier. In the spirit of making the development easier I have been working on eliminating the Windows machine from my office. I am currently using various virtual machine solutions such as VMWare and Sun’s VirtualBox in order to run Windows XP inside a virtual machine on my Ubuntu desktop.

What I have just been working on is building the Windows debugger entirely under Linux, without even having to boot into windows. In order to do this I employ the mingw32 cross-compiler which produces Windows binaries. Since the autobuilding tools automatically can utilize the cross-compiler by using the –host and –build options it is usually not so hard to get working.

In order to install mingw32 I issued the following command:

$> sudo apt-get install mingw32

The first thing I needed to do was download the wxWidgets archive for Windows called wxMSW. I downloaded and unzipped it to my development directory. For the debugger I usually want to link the application statically rather than dynamically. This is because dynamic linking involves having to distribute the new libraries.

Then I created a subdirectory called mingw32-static and moved into that directory.

$> cd wxMSW-2.8.9
$> mkdir mingw32-static
$> cd mingw32-static
$> ../configure --build=i586-mingw32msvc --host=i586-mingw32msvc --disable-shared --prefix=/usr/local/wx-2.8.9-mingw32
$> make -j2
$> sudo make install

Notice that when I issued the make command I added the -j2 option in order to allow make to fork several compilers. This causes the build to happen a lot faster and since I have a dual core P4 system the build occurs very quickly. At work I have a server with 8 cores and it can build like lightning.

When I issued the configure script I passed the –prefix=/usr/local/wx-2.8.9-mingw32 option which specifies where make should install the package when the make install command is issued. Since I also have the Linux GTK wxWidgets libraries installed I made sure to specify a path with mingw32 in the name to differentiate it.

Well, thats all there is to making wxWidgets for Windows on the Linux platform. The only negative side effect that is the application generated using this technique will have to also distribute the mingwm10.dll. But this is not such a bad thing…

This entry was posted in Computers and tagged , , , , . Bookmark the permalink.

3 Responses to Building wxWidgets using mingw32 on Ubuntu Linux

  1. Thanks for the instructions. I’ve never done cross-compilation on Linux. I guess it’s time I tried it.

    What IDE or editor do you use on Linux for designing your apps? Do you use any GUI editor for wxWidgets?


  2. muman613 says:

    Hello Alexei,

    I don’t use any particular IDE for the GUI in the debugger. I use KDevelop for the C++ code.


  3. updx says:

    Thanks for this, i will try mingw32. I’d like to programming in c for windows.

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s