From HaskellWiki
< WxHaskell
Revision as of 09:11, 23 December 2008 by Shelarcy (talk | contribs) (Update building instruction for wxHaskell 0.11.0)
Jump to: navigation, search

Building wxWidgets and wxc with Microsoft Visual C++

The advantage of using Visual C++ is that the resulting libraries are smaller and faster than the gnu compiled ones. Furthermore, the debug version provides for automatic detection of memory leaks in the wxWidgets libraries and you get a warning when forgetting to deallocate wxWidgets objects. The drawback is that the configure scripts are not used and you will need to set some options manually.

If you want to use Visual C++ Express Edition, you must use Visual C++ 2008 Express Editions or higher. Because previous version requires installing Microsoft Platform SDK before building wxWidgets or wxHaskell.

We use the wxWidgets provided workspace directly:

  • wxWidgets 2.8: Open the $wxwin/build/msw/wx.dsw workspace. Select menu "Build/Batch build" and select all configurations by using the mouse and the shift key, when you click a marker, all configurations are deselected. Next you manually select the "Unicode Release" and "Unicode Debug" versions of all projects and press "Build". Afterwards, press "Save All" to save all your mouse clicking work :-)

If you want to use database access, openGL canvas and Graphics Context, you must edit $wxwin/include/msw/setup.h's #define wxUSE_*(* is target feature name) from 0 to 1.

After building wxWidgets, you need to run configure for the wxHaskell library.

> cd $wxhaskell
> ./configure --with-msc

If you want to use the debug version of the library, use the --wxc-libname option too.

> ./configure --with-msc --wxc-libname=wxcd

After configuration, first run make command to generate stc_gen.* files.

> make

Make will stop by following error.

> make: *** No rule to make target `out/wxc/wxc-msw2.8.9-0.11.0.dll', needed by `wxc'.  Stop.

Then go $wxhaskell/wxc directory. Here, you need to adapt the wxc-<em>version</em>.dsp project to reference the correct wxWidgets directory. Open the .dsp file in an editor and replace all occurrences of "..\..\wxWindows-2.8.9" or by the installed wxWidgets directory, i.e. $wxwin.

After adapting the project file, you can open the workspace wxc/wxc-<em>version</em>.dsw and build the "Unicode Release" and "Unicode Debug" versions of the C wrapper library.

And finally! – you can run make in the $wxhaskell directory to build the Haskell libraries.

> cd $wxhaskell
> make
> make install
> make wx
> make wx-install

User experiences

GHC 6.10.1, wxWidgets 2.8.9, wxHaskell 0.11.0 (binary)

  1. Download the wxhaskell binary from sourceforge
  2. Unpack wxhaskell-*.zip. And double-click wxhaskell-*\bin\wxhaskell-register.bat.
  3. wxhaskell-register.bat install wxHaskell to your system.

Assumptions (a.k.a. what I have tested)

  • GHC 6.4.2 (Jason Dagit reports success with GHC 6.5 as well).
  • Cygwin installation. See WxHaskell/Cygwin for detail, but broadly, you need Cygwin bash and install binaries.
  • wxWidgets built/installed in a path with no spaces in it. Actually you can use a path with spaces but there are a few rules. For example, I had ghc installed to this location:
    C:\Program Files\Visual Haskell
    So this required me to use the following configure command:
    ./configure --libdir=C:/Progra~1/Visual~1

The two important things here are: 1) You must use the forward slash and 2) you cannot use spaces.

Next I found that I needed to add C:\Program Files\Visual Haskell to my path so that the wxHaskell dlls could be located by windows.

  • Environment variables:
    • PATH should include MinGW and Cygwin binary directories. MinGW must come before Cygwin in PATH.
    • WXHASKELL environment var points to wxHaskell install directory.
    • WXWIN environment directory points to wxWidgets install directory.

For more detailed information, see Installing wxWidgets 2.6.4 on Microsoft Windows 9x/ME, Windows NT, Windows 2000, Windows XP, and Windows CE.

See also