##### Views

(Difference between revisions)
 Revision as of 02:43, 29 October 2008 (edit) (Add --partial option to darcs get command)← Previous diff Current revision (15:33, 19 July 2011) (edit) (undo)m (→Quick start) (48 intermediate revisions not shown.) Line 1: Line 1: - === Building from sources === + === Quick start === - In principle we recommend the use of [[WxHaskell/Download|binary releases]], but wxHaskell also has a build system to compile directly from sources. The build process has been specialized for three main platforms: + Getting wxHaskell is easy on MacOS X and Linux. It's slightly less easy on Windows. - * '''unix-gtk'''. General unix systems with GTK. + Basically, + + # Get g++ (MinGW on Windows, Developer Tools on Mac) + # Get wxWidgets + # Build wxHaskell + + > cabal install wx + + See the platform specific quick starts for more details: + + * [[../Windows/]] + * [[../MacOS X/]] + * [[../Linux/]] + + === Supported Configurations === + + The build process has been tested against three main platforms: + + * '''unix-gtk'''. General Unix systems with GTK. * '''macosx'''. Mac OS X. * '''macosx'''. Mac OS X. - * '''windows'''. General windows systems (i.e. win95 to winXP). We support both building with the Microsoft Visual C++ compiler version 6, 7 and 8 ('''windows-msc''') and building with the gnu mingw32 C compiler ('''windows-mingw'''). + * '''windows'''. General windows systems (i.e. win95 to winXP).
- wxHaskell has been build successfully on (at least) the following configurations: + We support building only with the gnu mingw32 C compiler ('''windows-mingw''').
''Please note that we have discontinued support for Microsoft compilers in the build system.'' + + wxHaskell has been built successfully on (at least) the following configurations: - * '''windows'''. Windows 98, windows 2000, and windowsXP, using wxMSW 2.4.x, 2.5.x, and 2.6.x. + * '''windows'''. Windows 98, 2000, XP, and 7, using wxMSW 2.8.x. - * '''macosx'''. Mac OS X 10.2 (Jaguar) and 10.3 (Panther) with ghc 6.2.x and wxMAC 2.4.2 and 2.5.x. + * '''macosx'''. Mac OS X 10.5 (Leopard) and 10.6 with wxMAC 2.8.x. - * '''unix-gtk'''. Red Hat Linux 10 (Fedora), FreeBSD, and Gentoo Linux, using wxGTK 2.4.2, 2.5.x, and 2.6.x. + * '''unix-gtk'''. Red Hat Linux 10 (Fedora), FreeBSD, and Gentoo Linux, using wxGTK 2.8.x. (Unfortunately, there are still build problems on Sun Solaris – we are looking for build volunteers :-) (Unfortunately, there are still build problems on Sun Solaris – we are looking for build volunteers :-) === Prerequisites === === Prerequisites === - Ensure you have a recent [http://www.haskell.org/ghc GHC] compiler – version 6.8.1 is recommended (but any version >= 5.04.3 will work). In principle, any Haskell98 compiler that supports the standard FFI libraries will also work. + Ensure you have a recent [http://www.haskell.org/ghc GHC] compiler – version 6.10.3 or higher is recommended. In principle, any Haskell 98 compiler that supports the standard FFI libraries along with cabal install should work. We have discontinued support for building without cabal. - * '''windows''': you need the cygwin environment together with the mingw compiler. The build process is very sensitive to the cygwin setup and there is a separate [[WxHaskell/Building_on_Cygwin|guide]] for installing cygwin properly. + * '''Windows''': You will need wx-config for Windows, MinGW 5.1.6 and MSYS 0.1.11 (these are the latest versions at the time of writing). You must select the C++ compiler option when installing MinGW. - * '''macosx''': you need to install the gcc compiler, which is part of the Apple Developer Tools. These tools are shipped with Panther and are installed by invoking Applications/Installers/Developer Tools/Developer.mdmg. + ** MinGW 5.1.6 can be downloaded from [http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer MinGW] - * '''ghci''': the GHCi interpreter only works with wxWidgets version '''2.4.2''' on Windows platforms. + ** MSYS 0.1.11 can be downloaded from [http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe MSYS] - Next, you should install the previous stable version (2.6.4) of [http://www.wxwidgets.org wxWidgets] for your platform. (wxHaskell doesn't support latest stable version (currently 2.8.4) now.) We assume in this guide that the variable $wxwin points to your wxWidgets installation directory, for example: ~/dev/wxGTK-2.6.4. + ** wx-config can be downloaded from [http://wxconfig.googlepages.com/ wx-config] - * '''windows''': ghci only works with wxWidgets 2.4.2. Since this wxWidgets version is very stable, it is recommended on windows platforms. + * '''Mac OS X''': you need to install the gcc compiler, which is part of the Apple Developer Tools. These tools are shipped with Panther and are installed by invoking Applications/Installers/Developer Tools/Developer.mdmg. - * '''macosx''': MacOS X works best with wxWidgets 2.5.4. The previous stable release (wxMAC-2.6.4) does not display menus properly. + - If you have a [[WxHaskell/Download|source release]] of wxHaskell, just unpack it in a suitable directory. In the following descriptions, we assume that the variable$wxhaskell points to your installation directory, for example: ~/dev/wxhaskell. + - (Note: GHC 6.6.x or higher can't build old source releases. So you must get source from darcs by below command.) + You should install the current stable version ([http://sourceforge.net/projects/wxwindows/files/wxMSW/2.8.10/wxMSW-2.8.10-Setup.exe/download 2.8.10]) of [http://www.wxwidgets.org wxWidgets] for your platform - versions older than 2.8.1 are no longer supported. Build instructions are given for Windows - on most other platforms you should be able to obtain wxWidgets using your package manager (you may need -developer packages). - If you do not have a source release of wxHaskell, you need to check it out from the [http://code.haskell.org/wxhaskell/ darcs repository]. Darcs creates a wxhaskell directory for you; we assume in the following example that your $wxhaskell directory will be ~/dev/wxhaskell. + We assume in this guide that the variable$wxwin points to your wxWidgets installation directory, for example: ~/dev/wxGTK-2.8.10. - + -
> cd ~/dev                                                                                                                                                                                                                                                                                                                                                    +
> cd $wxwin > cd$wxwin
Line 61:                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Line 97:
> make                                                                                                                                                                                                                                                                                                                                                                                                                                    > make
> make install
> make install
- Notes: + -
+ ==== Testing wxWidgets build ==== -
+ -
• --enable-unicode to build a unicode library (required for 0.10 and up).
• + -
• --with-odbc to enable [http://wxhaskell.sourceforge.net/doc/Graphics.UI.WXCore.Db.html database access].
• + -
• --with-opengl to enable the [http://wxhaskell.sourceforge.net/doc/Graphics.UI.WXCore.OpenGL.html openGL canvas].
• + -
• --enable-sound to enable playback of wave audio files. (--enable-wave on wxWidgets 2.4.x. And this option is diffrent with below option. You can play sound without no-control by this feature. But ... if you use below media control, it requires to make Control on your Window.)
• + -
• --enable-mediactrl to enable the media control. (recommended for wxWidgets version >= 2.6.x)
+ -
• + -
• Do not forget to run make install; this installs a utility called wx-config that is used by the other projects.
• + -
• Do not forget to install 'contrib' hierarchy libraries. Now latest darcs' source depends on 'contrib' hierarchy libraries.
• + -
• '''unix-gtk''': if you want to use the GTK-'''2''' toolkit, you need to configure with unicode support since current wxHaskell can handle only unicode library. Try for example: + -
../configure --with-gtk --enable-gtk2 --enable-unicode
• + -
• '''macosx''': you might need to run rehash after make install in order to add the wx-config utility to the search path cache.
• + -
• '''windows''': sometimes the header file $wxwin\include\wx\msw\popupwin.h is not properly copied when make install is run, and you need to copy it manually to the install directory (for example /usr/local/include/wx/msw). (if this file is not copied, C compilation of wxHaskell will fail). + Now try out a few samples of wxWidgets to see if it all works correctly: Now try out a few samples of wxWidgets to see if it all works correctly: Line 87: Line 109: And also try if wx-config works too: And also try if wx-config works too: - > wx-config --version + > wx-config -v + + ChengWei: I've found that if you put wx-config in some system directories, such as c:\windows\system32, 'cabal install wx' will complain "wx-config: does not exist". To put it in another directory in %PATH% will solve this problem. Tested on Windows 7, Haskell platform 2010 2.0.0.0. + === Building wxHaskell === === Building wxHaskell === - First, we configure the library for your platform. + Since wxHaskell 0.12.1.1, we only support building using Cabal. - > cd$wxhaskell                                                                                                                                                                                                                                                                                                                                               +                                                                      For all platforms installation is straightforward, provided that:
-                                                                                                        > ./configure --enable-split-objs --hcprof
+ # wx-config is somewhere in the path - Notes: + # The WXWIN environment variable points to the root of your wxWidgets installation - * You can run configure first with the --help option. This also shows the values of command-line options and is an excellent check to see if everything is set up correctly. If the settings do not make sense, it might be that the wx-config utility is not found – maybe you have forgotten to run make install on wxWindows? + # WINDOWS PLATFORMS ONLY: You may also need to set WXCFG=gcc_dll\mswu - * You should pass the --with-opengl option to configure if you specified this flag when configuring wxWidgets (or you will get link errors). + - * You should pass the --with-contrib option to configure if you also installed contrib libraries after building wxWidgets (or you will get link errors). + - * By default, the library is installed in the wxWidgets install directory. You can specify another directory with the prefix option of configure: ./configure --prefix=/usr/local. Any directory that is on your library search path will do. + - * '''windows-msc'''. Read the [[WxHaskell/Building_on_Windows|notes]] on building wxHaskell with Visual C++. + - * '''ghc 6.0.1, wxhaskell 0.8''': In the file wxcore/src/Graphics/UI/WXCore/WxcObjects.hs you need to switch the parameters to newForeignPtr on line 172. In the file wx/src/Graphics/UI/WX/Controls.hs you need to replace the import of Data.Typeable by Data.Dynamic. + - After configuration, we build and install the libraries (and take some more time to drink more coffee :-). + -
> make                                                                                                                                                                                                                                                                                                                                                        +                                                                      You can then install wxhaskell as follows (''in a Windows cmd.exe shell, not an MSys shell''):
-                                                                                                        > make install                                                                                                                                                                                                                                                                                                                                                     +
-                                                                                                        > make wx                                                                                                                                                                                                                                                                                                                                                          +                                                                      > cabal update
-                                                                                                        > make wx-install
+ > cabal install wx - Notes: + -
+ Note that on Windows 7 machines, your command window must be running as Administrator. -
• If make install fails when building the ghc package, you might not have administrator priviliges. Either run it as an administrator or configure in such a way that you use a [http://haskell.cs.yale.edu/ghc/docs/latest/html/users_guide/packages.html local ghc package]: + -
./configure --package-conf=~/mypackages
• + Note that on Unix systems, you may prefer something like -
• You can generate documentation with make doc.
• + -
• The libraries can be uninstalled with make uninstall.

### 4 Getting wxWidgets

wxHaskell 0.12.x.x supports wxWidgets > 2.8.

• Windows:
• You can use the wxPack prebuilt binaries (the MinGW ones)
• Alternatively, you can build using the MinGW compiler - instructions below.
• Mac OS X
• Tiger - do not use the wxMac 2.5 that comes pre-installed.
• Leopard - wxHaskell now supports wxWidgets 2.8.
• Linux - the wxWidgets that ships with your system (as long as it's the 2.8 one and not the 2.6 one) should work.

See the wxWidgets site for more details.

### 5 Building wxWidgets (usually optional)

#### 5.1 On Windows

Note: Microsoft compilers are no longer supported. The cabal build system cannot understand the output of wx-config for Microsoft compilers.

Note: The Haskell Platform 2010.1.0.0 installer shipped without C++ support. If you want to build wxHaskell on Windows using this Haskell Platform, please see [1]

Note: At the time of this writing there is a MinGW bug that may prevent you from building wxWidgets. The solution for now is to use tdm-gcc. Check the wxWidgets wiki for details.

Using the MSYS shell, and making sure that you have the C++ compiler option installed for MinGW as it is 'not' the default:

> cd /c/path/to/wxWidgets-2.8.10/build/msw
> mingw32-make -f makefile.gcc BUILD=release MONOLITHIC=1 SHARED=1 UNICODE=1


This will take quite some time and generate lots of text in the MSYS shell. Assuming it is successful, a DLL is generated in /c/path/to/wxWidgets/gcc_dll, which you will need to copy to a location where it can be found when running your executables.

#### 5.2 On Unix systems

You should follow the instructions on the wxWidgets website if there are no suitable packages for your environment. You probably want to use GCC to build wxWidgets, as this makes it more likely that cabal will understand the output of wx-config.

On most Unix platforms, wxWidgets build goes something like: create a mybuild directory in the wxWidgets directory, and run configure and make from that directory (and take the time to get some coffee :-).

> cd $wxwin > mkdir mybuild > cd mybuild > ../configure --enable-unicode > make > make install > cd ../contrib/src > make > make install #### 5.3 Testing wxWidgets build Now try out a few samples of wxWidgets to see if it all works correctly: > cd ../../samples/controls > make > ./controls Note that you build from the local samples directory that resides in the mybuild directory. And also try if wx-config works too: > wx-config -v ChengWei: I've found that if you put wx-config in some system directories, such as c:\windows\system32, 'cabal install wx' will complain "wx-config: does not exist". To put it in another directory in %PATH% will solve this problem. Tested on Windows 7, Haskell platform 2010 2.0.0.0. ### 6 Building wxHaskell Since wxHaskell 0.12.1.1, we only support building using Cabal. For all platforms installation is straightforward, provided that: 1. wx-config is somewhere in the path 2. The WXWIN environment variable points to the root of your wxWidgets installation 3. WINDOWS PLATFORMS ONLY: You may also need to set WXCFG=gcc_dll\mswu You can then install wxhaskell as follows (in a Windows cmd.exe shell, not an MSys shell): > cabal update > cabal install wx  Note that on Windows 7 machines, your command window must be running as Administrator. Note that on Unix systems, you may prefer something like > sudo cabal install --global wx  Windows developers who don't update environment variables can do something like this in an MS-DOS shell: > Set CPLUS_INCLUDE_PATH=C:\MinGW\include\c++\3.4.5;C:\MinGW\include\c++\3.4.5\mingw32\ > Set WXWIN=C:\path\to\wxWidgets-2.8.10 > Set WXCFG=gcc_dll\mswu > cabal install wx  The Windows installation is global by default. #### 6.1 Out of memory errors There have been reports of out of memory errors when compiling wxcore on some machines, notably 64 bit Linux hosts. Wxcore contains some very large auto-generated source files, and increasing the memory available to the GHC runtime can help. Try something like: > export GHCRTS='-M512m'  to allocate 512 MB to the GHC RTS. This has been reported to be sufficient. ### 7 Source Release You can obtain a source release of wxHaskell from the darcs repository. Darcs creates a wxHaskell directory for you; we assume in the following example that your$wxHaskell directory will be ~/dev/wxhaskell.

> cd ~/dev
> darcs get --lazy --set-scripts-executable http://code.haskell.org/wxhaskell/

You then build each of the key components in order:

> cd ~/dev/wxhaskell/wxdirect
> cabal install
> cd ../wxcore
> cabal install
> cd ../wx
> cabal install


If everything succeeded, you should be able to run a test program.

> cd samples/wx
> ghc -package wx -o helloworld HelloWorld.hs
> ./helloworld

Notes:

macosx: wxHaskell programs need to be turned into application bundles before they can be run. Look at the Mac OS X notes for more information. You can also run the examples from GHCi – a great development environment!

> ghci -package wx BouncingBalls.hs
> main

Notes:

wxHaskell programs are not always properly reïnitialized when started the second time from a GHCi prompt. This is due static variables in the wxWidgets C++ code, and we are working with wxWidgets developers to remove those bugs. Currently, GHCi only works well with wxWidgets 2.4.2. gtk: Unfortunately, one can only start a wxWidgets program once with GHCi on GTK (rendering it useless). macosx. You need to use a special command to run wxHaskell applications, see the Mac OS X notes from more information. Have fun!