WxHaskell/Install

From HaskellWiki
< WxHaskell
Revision as of 13:16, 17 February 2008 by EricKow (talk | contribs)
Jump to navigation Jump to search

Overview

This page describes how to get a working wxHaskell installation on various platforms. This is not as easy as it might be, as the wxHaskell project has not received much attention since around May 2005 (at time of writing). This means that the available binary packages are unlikely to meet your needs, and you will probably have to build from source.

Note further that much of this is getting outdated fast. Current development on wxHaskell takes place in the darcs repository at http://darcs.haskell.org/wxhaskell .

Getting wxWidgets

wxHaskell would not build cleanly for me with the most recent variants of wxWidgets. Under Windows, I was successful in compiling against wxWidgets 2.4.2. Mac OSX (Tiger) has a pre-installed version of wxWidgets 2.5, and it is possible to compile against this provided that a patch is applied - see the section on Mac OSX for details.

  • For PC running Windows: I recommend wxWidgets 2.4.2. Newer versions are alleged to build, but I (and others) have had problems. If you want to use ghci, you definitely want 2.4.2. Download from Sourceforge. Unless you particularly wish to build from source, the wxMSW-2.4.2-setup.zip download is fine (it provides a Windows installer for most of what you need. Documentation is a separate (and useful) download. You will make your life easier if you install to a path which does not contain spaces - my recollection is that this is not the default provided by the installer.
  • For Mac running OSX (Tiger): Download it from wxWidgets.org.
  • For Linux: Recommendations welcome...
  • wxWidgets 2.6.3: Jinwoo Lee, in a mail to wxhaskell-users and haskell-cafe mailing list, claims success in compiling wxHaskell against wxWidgets 2.6.3.
    • Jinwoo writes: "I had problems when compiling wxhaskell 0.9.4 using wxWidgets 2.6.3. And I found out that in wxWidgets 2.6.3, some DB-related field names have changed:
      • columnSize --> columnLength
      • bufferLength --> bufferSize
    • So I modified the file "db.cpp" (wxc/src/db.cpp), and succeeded to compile.

I'm attaching the modified file." (Editor's note: see http://www.haskell.org//pipermail/haskell-cafe/2006-July/thread.html#17042 to obtain the modified db.cpp)

Getting wxHaskell

Obtain wxHaskell sources from Sourceforge.

OSX caveats:

  • The installation of wxWidgets provided with OSX Tiger will not work, as it does not have the wxThread symbols that wxHaskell does want to link against.
  • Programs compiled with wxHaskell do not work by default: you need to run macosx-app on them to let Mac OS X understand that the binary needs Carbon to do its UI.

Building and installing

Windows

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 page 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.

After wxHaskell installed I started getting panics from 'ghc -package wx':
http://www.haskell.org/pipermail/glasgow-haskell-bugs/2005-October/005632.html
And I found a solution here:
http://www.haskell.org/pipermail/glasgow-haskell-bugs/2005-October/005639.html

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.

Mac OSX

MacIntel, Tiger (10.4.11), GHC 6.8.2, wxWidgets 2.6.4, wxHaskell 0.10.2 (hackage)

built on 2008-02-16

  1. Download and install wxWidgets for mac (wxMac 2.6.4) from http://www.wxwidgets.org/
    • I changed into the wxMac topdirectory and used: ./configure --disable-monolithic --enable-display --enable-unicode --with-opengl --with-mac --without-odbc --enable-mediactrl && make && sudo make install
    • sudo mkdir -p /usr/local/wxhaskell/bin
    • sudo ln -s /usr/local/bin/wx-config /usr/local/wxhaskell/bin
  2. sudo cabal install wx-core
  3. cabal install wx
  • Enjoy. The TimeFlows and BoucingBalls examples still suffer from not having a correct default background color. This should not affect you too much: just explicitly set the background color.
    • Note that you need to run macosx-app on the programs you have built before you can manipulate the windows that program puts up. This installation process puts it in /usr/local/wxhaskell/bin/macosx-app
  • Does wxWidgets 2.8.0 work at all? [as of 2008-02-16, no]

Linux

Sources

I (Roconnor) managed to build wxHaskell from sources. I built wxGTK-2.6.4 from sources with the configuration:

/usr/local/src/wxGTK-2.6.4/mybuild$ ../configure --disable-shared --with-opengl --enable-sound --enable-unicode

Notice the --enable-unicode, which is the exact opposite of the what the current (2007-10-16) documentation says to do. To get --with-opengl to work I have the ubuntu/debian virtual package libglu-dev installed. The --with-opengl is probably not necessary.

For some reason my system wasn't looking for shared libraries in /usr/local/lib. This caused problems later for me. I had to add

/usr/local/lib

to my /etc/ld.so.conf before running sudo ldconfig after installing wxGTK.

After I build wxHaskell from the darcs repository, configured with ./configure --with-opengl, and followed the usual installation documentation from here on.

Debian

For Debian Linux systems (as long as there's no .deb package):

  • Fetch the rpm package from http://wxhaskell.sourceforge.net/download.html
  • make sure you have wxWidgets installed (libraries and developer files)
  • if you haven't done this already, install the debian package "alien": apt-get install alien
  • use alien to install the rpm package: alien -i wxhaskell....rpm
  • use ghc-pkg to add the packages wxcore and wx to ghc's package configuration file:
    cd /usr/lib/ghc-6.2.1/wxhaskell-0.7
    ghc-pkg -D wxhlibdir=/usr/lib/ghc-6.2.1/wxhaskell-0.7 -ai wxcore.pkg
    ghc-pkg -D wxhlibdir=/usr/lib/ghc-6.2.1/wxhaskell-0.7 -ai wx.pkg

Another way for Debian systems:
use the repository "deb http://haskell-unsafe.alioth.debian.org/archive/i386 unstable ."

A way that surely works:

Gentoo

wxHaskell is available in portage for x86, amd64, sparc and ppc

ACCEPT_KEYWORDS="~x86" emerge wxhaskell

(users of other arches should use their arch keywrods as appropriate)

Fedora Core 6

There is no wxHaskell package to go with the ghc-6.6 packages. You will have to compile it yourself. This a simple matter of:

  • Installing wxGTK:
    • yum install wxGTK-devel
  • Getting the sources:
  • Configuring, building and installing:
    • configure --with-opengl && make && make install && make wx && make wx-install

Troubleshooting

Problems compiling

  • Configure Succeeded (and nothing more)
    • Solution: Upgrade to the latest version of Cabal and cabal-install (darcs)
  • error build wxcore
    • /usr/libexec/gcc/i686-apple-darwin8/4.0.1/libtool: can't locate file for: -lwx_macu_media-2.6
    • /usr/libexec/gcc/i686-apple-darwin8/4.0.1/libtool: file: -lwx_macu_media-2.6 is not an object file (not allowed in a library)
    • Solution: try --enable-mediactrl in the wxWidgets configure
  • Too many levels of symbolic links (Linux)
    • UNKNOWN!

App-compilation issues

  • sample application dies with something like (Linux)
    • /usr/lib/libwxc-gtk2.6.3-0.10.1.so: undefined reference to `wxWindowBase::Hide()'
    • ...
    • `wxLog::AddTraceMask(wxString const&)' /usr/lib/libwxc-gtk2.6.3-0.10.1.so: undefined reference to `wxHtmlHelpController::GetFrame()'
    • /usr/lib/libwxc-gtk2.6.3-0.10.1.so: undefined reference to `wxPrintData::SetQuality(int)'
    • collect2: ld returned 1 exit status
    • Solution Configure wxhaskell --with-opengl

Runtime issues

  • sample applications just sit there doing nothing (MacOS X)
    • Solution: macosx-app the application
  • sample applications segfault!
    • Solution: use wxWidgets 2.6 (2008-02-16: wxhaskell doesn't work yet with 2.8)
  • wxhaskell builds fine, but sample applications do this:
    • dyld: Symbol not found: __ZN8wxThread11TestDestroyEv
    • Referenced from: /usr/local/wxhaskell/lib/libwxc-mac2.8.7-0.10.1.dylib
    • Expected in: flat namespace
    • trace trap ./BouncingBalls
    • Solution: try --enable-shared in wxWidgets config


Old tips

WARNING: potentially obsolete

MacOSX Errors

  • Problems compiling wxHaskell (something like the below)
    /tmp/ghc29861.s:4379: Unknown pseudo-op:
    .subsections_via_symbol

    Make sure you have at least Xcode 1.5 (gcc 3.3 build 1671). Xcode 1.1 (gcc build 1495) is not enough
  • More linker trouble: #
ld: out/wxc/master.o undefined symbol 36311 (__ZdaPv) can't be a weak definition
/usr/bin/libtool: internal link edit command failed
make: *** [out/wxc/libwxc-mac2.6.2-0.9.4.dylib] Error 1
    • Fix seems to be to add the gcc 3.3 version of libstdc++ to your dylib: http://page.freett.com/shelarcy/log/2006/diary_02.html
    • If you use gcc 4, try to add the following linker flags "-lSystemStubs -shared-libgcc -lstdc++-static". (libstdc++-static.a is part of XCode 2.3)
  • [OBSOLETE?] If you get linker errors like it not being able to find _TextziParserCombinatorsziParsecziChar_alphaNum_closure, try editing config/config.mk and setting HC=ghc -lHSparsec. This is likely not a mac-specific problem but related to the use of GHC 6.2 over 6.0.1. (not sure if this is still valid)
  • When compiling your Haskell program:
    ld: /usr/lib/crt1.o illegal reference to symbol: __objcInit defined in indirectly referenced dynamic library /usr/lib/libobjc.A.dylib
  • [OBSOLETE?] Adding -framework AppKit to the compiler switches for your Haskell program seems to help
  • Certain buttons and widgets are not active

The last point is possibly a wxWidgets or a wxHaskell bug - basically, widgets in "boxed" environments do not react to user. Take out the box, and you're ok.