Difference between revisions of "Diagrams/Install"

From HaskellWiki
Jump to navigation Jump to search
(added Xquartz step)
(Added some details about getting Cairo to install on OS X)
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
  +
= Default installation =
The first step is to install the [http://haskell.org/platform Haskell Platform], if you don't already have it. You will also need to have gtk and cairo (along with development headers) installed through your operating system. After that, it should ''ideally'' be enough to run
 
   
 
The first step is to install the [http://haskell.org/platform Haskell Platform], if you don't already have it. Then it should be enough to simply run
cabal install gtk2hs-buildtools diagrams
 
   
  +
cabal install diagrams
This will probably work under Linux/Unix but some workarounds may currently be required on Windows or Mac OS X; see below. Please edit this page to add information about any problems you encounter, workarounds you discover, etc.
 
   
  +
By default this will give you <code>diagrams-core</code> (core data structures), <code>diagrams-lib</code> (standard library), <code>diagrams-contrib</code> (user-contributed modules), and <code>diagrams-svg</code> (native Haskell backend outputting SVG files).
== Installing on Linux/Unix ==
 
   
  +
== Windows installation problems ==
As far as we know there are currently no issues installing diagrams on Linux/Unix systems.
 
   
  +
There is [https://github.com/diagrams/diagrams-contrib/issues/14 a report] that <code>diagrams-cairo</code> may not build on Windows, due to issues with the <code>numeric-extras</code> package (see also [https://github.com/ekmett/numeric-extras/issues/1 this <code>numeric-extras</code> bug report]). In the meantime, if you do not need <code>diagrams-contrib</code> you can simply do without it: instead of doing <code>cabal install diagrams</code>, just execute, for example,
== Installing on Windows ==
 
   
  +
<code>cabal install diagrams-core diagrams-lib diagrams-svg</code>
Cairo can unfortunately be difficult to install on Windows.
 
  +
 
= Installing the cairo backend =
  +
  +
As of the 0.6 release of diagrams, the SVG backend has replaced the cairo backend as the default "out of the box" backend. However, the cairo backend still has a few advantages (support for text alignment, embedded images, and animations, as well as the ability to output PNG, PDF, and PS files). However, installing the cairo backend can be more challenging, especially on OS X.
  +
  +
You will need to have the cairo C library (along with development headers) installed through your operating system's package manager or otherwise. After that, it should ''ideally'' be enough to run
  +
 
cabal install gtk2hs-buildtools
  +
cabal install -fcairo diagrams
  +
  +
(If you ''don't'' want the SVG backend you can add the flag <code>-f-svg</code>.) If you have already installed <code>gtk2hs-buildtools</code> in the past then you probably don't need to reinstall it; though note that in order to build <code>cairo</code> under GHC 7.6 you need to have a recent enough version of <code>gtk2hs-buildtools</code>; otherwise you will get some error messages having to do with the FFI.
  +
 
This will probably work under Linux/Unix but some workarounds may currently be required on Windows or Mac OS X; see below. Please edit this page to add information about any problems you encounter, workarounds you discover, etc.
  +
 
== Installing on Windows ==
   
 
[http://jystic.com/2010/10/20/installing-gtk2hs-on-windows/ Here are instructions] for installing gtk2hs on Windows. They work with the exception of the [http://hackage.haskell.org/trac/gtk2hs/ticket/1203 issue described here], which can be circumvented by passing the --global option to 'cabal install cairo' (if you don't mind installing cairo in the global package database).
 
[http://jystic.com/2010/10/20/installing-gtk2hs-on-windows/ Here are instructions] for installing gtk2hs on Windows. They work with the exception of the [http://hackage.haskell.org/trac/gtk2hs/ticket/1203 issue described here], which can be circumvented by passing the --global option to 'cabal install cairo' (if you don't mind installing cairo in the global package database).
Line 30: Line 45:
   
 
* type gtk-demo to check gtk installed ok.
 
* type gtk-demo to check gtk installed ok.
  +
  +
* It may be necessary to set a path for pkg-config to find some install packages: <code>export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig</code>
   
 
* cabal install gtk2hs-buildtools
 
* cabal install gtk2hs-buildtools

Revision as of 16:31, 26 August 2013

Default installation

The first step is to install the Haskell Platform, if you don't already have it. Then it should be enough to simply run

 cabal install diagrams

By default this will give you diagrams-core (core data structures), diagrams-lib (standard library), diagrams-contrib (user-contributed modules), and diagrams-svg (native Haskell backend outputting SVG files).

Windows installation problems

There is a report that diagrams-cairo may not build on Windows, due to issues with the numeric-extras package (see also this numeric-extras bug report). In the meantime, if you do not need diagrams-contrib you can simply do without it: instead of doing cabal install diagrams, just execute, for example,

cabal install diagrams-core diagrams-lib diagrams-svg

Installing the cairo backend

As of the 0.6 release of diagrams, the SVG backend has replaced the cairo backend as the default "out of the box" backend. However, the cairo backend still has a few advantages (support for text alignment, embedded images, and animations, as well as the ability to output PNG, PDF, and PS files). However, installing the cairo backend can be more challenging, especially on OS X.

You will need to have the cairo C library (along with development headers) installed through your operating system's package manager or otherwise. After that, it should ideally be enough to run

 cabal install gtk2hs-buildtools
 cabal install -fcairo diagrams

(If you don't want the SVG backend you can add the flag -f-svg.) If you have already installed gtk2hs-buildtools in the past then you probably don't need to reinstall it; though note that in order to build cairo under GHC 7.6 you need to have a recent enough version of gtk2hs-buildtools; otherwise you will get some error messages having to do with the FFI.

This will probably work under Linux/Unix but some workarounds may currently be required on Windows or Mac OS X; see below. Please edit this page to add information about any problems you encounter, workarounds you discover, etc.

Installing on Windows

Here are instructions for installing gtk2hs on Windows. They work with the exception of the issue described here, which can be circumvented by passing the --global option to 'cabal install cairo' (if you don't mind installing cairo in the global package database).

Here is a discussion about the most recent difficulties.

Installing on Mac OS X

  • make sure you have Xquartz (aka X windows intalled). GTK needs it.
  • make sure you're using a 64bit haskell install (you can check this by typing maxBound :: Int in ghci and seeing if you get 9223372036854775807).
  • make sure you're using homebrew, and uninstall gtk and **ALL** of its dependencies (you can do that yourself e.g. type brew list | xargs brew uninstall but note this will remove *all* homebrew packages).
  • type brew update
  • type brew install gtk
  • type gtk-demo to check gtk installed ok.
  • It may be necessary to set a path for pkg-config to find some install packages: export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig
  • cabal install gtk2hs-buildtools
  • cabal install gtk
  • If you want to try the example in the diagrams tutorial type cabal install diagrams-cairo.
  • Some users report problems with chart-gtk (which has nothing to do with diagrams) so ignore any other installation instructions which tell you to install it and run an example program called plott.

Old instructions (now superseded):

Here are instructions for getting gtk installed under OS X Lion with GHC 7.2. They should also work for 7.4.

Here is more discussion about installation under OS X Lion. See also this reddit thread.