Difference between revisions of "Hmatrix on Mac OS X"

From HaskellWiki
Jump to navigation Jump to search
m (Word fix)
m
 
(13 intermediate revisions by 9 users not shown)
Line 1: Line 1:
  +
[[Category:How to]]
Here are some notes on getting [http://dis.um.es/~alberto/GSLHaskell/ GSLHaskell] running under MacOS X 10.4 using [http://www.macports.org/ MacPorts]. These notes may be incomplete, and the details may change slightly in the future.
+
Here are some notes on getting [http://www.hmatrix.googlepages.com/ hmatrix] running under [[Mac OS X]] 10.4 or 10.5 using [http://www.macports.org/ MacPorts] or [http://finkproject.org/ fink].
  +
  +
These notes may be incomplete or even incorrect, but should point you in the right direction. The latest version of ''hmatrix'' considered here is 0.5.2.2.
   
 
Please update this page with anything you discover along the way.
 
Please update this page with anything you discover along the way.
Line 5: Line 8:
 
== Installing GHC using MacPorts ==
 
== Installing GHC using MacPorts ==
   
First, you will want to install GHC using MacPorts, not the standalone installers. Assuming that you have uninstalled any other versions of ghc, type:
+
First, you will want to install GHC using MacPorts, not the standalone installers. ''No sure why?'' Assuming that you have uninstalled any other versions of ghc, type:
   
 
sudo port install ghc
 
sudo port install ghc
Line 13: Line 16:
 
== Required libraries ==
 
== Required libraries ==
   
GSLHaskell requires working versions of GSL, BLAS and LAPACK. You can get GSL and BLAS from DarwinPorts:
+
The ''hmatrix'' package requires working versions of GSL, BLAS and LAPACK.
  +
  +
You can get GSL and BLAS from DarwinPorts:
   
 
sudo port install gsl
 
sudo port install gsl
   
  +
LAPACK, however, is already installed on MacOS X 10.4/10.5, namely in the ''vecLib'' (10.4) or ''Accelerate'' (10.5) frameworks. They appear to work fine with ''hmatrix'', though I didn't test very much.
The accelerated version of LAPACK bundled with MacOS X 10.4 appears to link with GSLHaskell, though I haven't tested it extensively.
 
   
  +
If you're using the 32-bit Haskell Platform and your MacPorts installation defaults to 64-bit binaries you want MacPorts to build universal binaries of gsl using:
== Installing GSLHaskell ==
 
   
  +
sudo port install gsl +universal
As of 20 Jan 2007, the Darcs version of GSLHaskell was easier to get working than the older tarball release. Download it as follows:
 
   
  +
or upgrade after an installation using:
darcs get http://dis.um.es/~alberto/GSLHaskell --partial
 
   
  +
sudo port upgrade --enforce-variants gsl +universal
Next, edit GSLHaskell/src/GSLHaskell.cabal to refer to the appropriate versions of BLAS and LAPACK:
 
  +
  +
otherwise you'll get the following error when you try to use hmatrix:
  +
  +
Loading package hmatrix-0.9.3.0 ... can't load .so/.DLL for: gsl (dlopen(/opt/local/lib/libgsl.dylib, 9):
  +
no suitable image found. Did find: /opt/local/lib/libgsl.dylib: mach-o, but wrong architecture)
  +
 
== Installing ''hmatrix'' ==
  +
  +
The [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmatrix most recent version] of ''hmatrix'' is available on [http://hackage.haskell.org/ HackageDB]. You can also download it from the darcs repository as follows:
  +
 
darcs get http://perception.inf.um.es/~aruiz/darcs/hmatrix --partial
  +
  +
''The following steps seem obsolete to me. -- Apfelmus''
  +
 
Next, edit hmatrix.cabal to refer to the appropriate versions of BLAS and LAPACK:
   
 
extra-libraries: gsl gslcblas LAPACK
 
extra-libraries: gsl gslcblas LAPACK
   
  +
you might also have to edit cc-options and ld-options to look in your ports directory:
To build and install GSLHaskell, type:
 
   
  +
cc-options: -O4 -I/opt/local/include
cd GSLHaskell/src
 
  +
ld-options: -L/opt/local/lib
runhaskell Setup.hs configure
 
runhaskell Setup.hs build
 
sudo runhaskell Setup.hs install
 
   
 
To build and install the package, type:
== Using GSLHaskell ==
 
   
 
runhaskell Setup.lhs configure
These instructions are awkward, and can probably be improved with better knowledge of GHC and/or Cabal.
 
 
runhaskell Setup.lhs build
 
sudo runhaskell Setup.lhs install
   
  +
== Using ''hmatrix'' ==
To load GSLHaskell using GHCI, you need to add two directories to your LD_LIBRARY_PATH:
 
   
 
To load ''hmatrix'' using GHCI, you need to add the directory containing the gsl shared library to your LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/:/opt/local/lib
 
  +
  +
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
  +
  +
=== Mac OS X < 10.10 ===
  +
  +
On Mac OS X 10.4, the LAPACK implementation is contained in the vecLib framework. For interactive use, type
  +
  +
ghci -framework vecLib
   
 
To build an example program using GHC, type:
 
To build an example program using GHC, type:
   
cd ../examples
+
cd examples
ghc --make -optl-L/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/
+
ghc --make -framework vecLib plot.hs
  +
plot.hs
 
  +
=== Mac OS X >= 10.10 ===
  +
  +
On Mac OS X Yosemite and above, vecLib is now called Accelerate.
  +
For interactive use, type
  +
  +
ghci -framework Accelerate
  +
  +
To build an example program using GHC, type:
  +
  +
cd examples
  +
ghc --make -framework Accelerate plot.hs
   
 
== Plotting with gnuplot and Aquaterm ==
 
== Plotting with gnuplot and Aquaterm ==
Line 60: Line 99:
 
export GNUTERM=aqua
 
export GNUTERM=aqua
   
You should now be able to build and run GSLHaskell/examples/plot.hs, and see three nicely anti-aliased plots. If you're using an xterm, you can also choose to leave GNUTERM unset to use gnuplot's built-in X11 support, which is uglier, but apparently allows rotation of 3D plots using the mouse.
+
You should now be able to build and run examples/plot.hs, and see three nicely anti-aliased plots. If you're using an xterm, you can also choose to leave GNUTERM unset to use gnuplot's built-in X11 support, which is uglier, but apparently allows rotation of 3D plots using the mouse.
  +
 
== Using fink ==
  +
  +
With minor changes the instructions work for fink. (I have already had the ghc and ghc-bin packages) In short:
  +
  +
fink install gsl
  +
fink install atlas
  +
fink install darcs
  +
darcs get http://perception.inf.um.es/~aruiz/darcs/hmatrix --partial
  +
(fink instal gnuplot)
  +
  +
runhaskell Setup.lhs configure
  +
runhaskell Setup.lhs build
  +
su
  +
runhaskell Setup.lhs install
  +
exit
  +
cd examples
  +
export LD_LIBRARY_PATH=/sw/lib/
  +
runhaskell tests
  +
OK, passed 100 tests.
  +
OK, passed 100 tests.
  +
etc.
  +
  +
Note that the latest version requires cabal 1.2 and the present fink version of ghc (6.6) has lower version. Nevertheless after installing cabal (which itself requires zlib and filepath) hmatrix installs without problems.
  +
  +
[[Category: Pages under construction]]

Latest revision as of 05:29, 8 June 2023

Here are some notes on getting hmatrix running under Mac OS X 10.4 or 10.5 using MacPorts or fink.

These notes may be incomplete or even incorrect, but should point you in the right direction. The latest version of hmatrix considered here is 0.5.2.2.

Please update this page with anything you discover along the way.

Installing GHC using MacPorts

First, you will want to install GHC using MacPorts, not the standalone installers. No sure why? Assuming that you have uninstalled any other versions of ghc, type:

sudo port install ghc

This may take several hours to bootstrap on a slow machine.

Required libraries

The hmatrix package requires working versions of GSL, BLAS and LAPACK.

You can get GSL and BLAS from DarwinPorts:

sudo port install gsl

LAPACK, however, is already installed on MacOS X 10.4/10.5, namely in the vecLib (10.4) or Accelerate (10.5) frameworks. They appear to work fine with hmatrix, though I didn't test very much.

If you're using the 32-bit Haskell Platform and your MacPorts installation defaults to 64-bit binaries you want MacPorts to build universal binaries of gsl using:

sudo port install gsl +universal

or upgrade after an installation using:

sudo port upgrade --enforce-variants gsl +universal

otherwise you'll get the following error when you try to use hmatrix:

Loading package hmatrix-0.9.3.0 ... can't load .so/.DLL for: gsl (dlopen(/opt/local/lib/libgsl.dylib, 9):
no suitable image found. Did find: /opt/local/lib/libgsl.dylib: mach-o, but wrong architecture)

Installing hmatrix

The most recent version of hmatrix is available on HackageDB. You can also download it from the darcs repository as follows:

darcs get http://perception.inf.um.es/~aruiz/darcs/hmatrix --partial

The following steps seem obsolete to me. -- Apfelmus

Next, edit hmatrix.cabal to refer to the appropriate versions of BLAS and LAPACK:

extra-libraries:    gsl gslcblas LAPACK

you might also have to edit cc-options and ld-options to look in your ports directory:

cc-options:         -O4 -I/opt/local/include
ld-options:         -L/opt/local/lib

To build and install the package, type:

runhaskell Setup.lhs configure
runhaskell Setup.lhs build
sudo runhaskell Setup.lhs install

Using hmatrix

To load hmatrix using GHCI, you need to add the directory containing the gsl shared library to your LD_LIBRARY_PATH:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib

Mac OS X < 10.10

On Mac OS X 10.4, the LAPACK implementation is contained in the vecLib framework. For interactive use, type

ghci -framework vecLib

To build an example program using GHC, type:

cd examples
ghc --make -framework vecLib plot.hs

Mac OS X >= 10.10

On Mac OS X Yosemite and above, vecLib is now called Accelerate. For interactive use, type

ghci -framework Accelerate

To build an example program using GHC, type:

cd examples
ghc --make -framework Accelerate plot.hs

Plotting with gnuplot and Aquaterm

Install gnuplot using MacPorts:

sudo port install gnuplot

If Aquaterm fails to compile, upgrade to the latest version of XCode. Tell gnuplot what terminal to use:

export GNUTERM=aqua

You should now be able to build and run examples/plot.hs, and see three nicely anti-aliased plots. If you're using an xterm, you can also choose to leave GNUTERM unset to use gnuplot's built-in X11 support, which is uglier, but apparently allows rotation of 3D plots using the mouse.

Using fink

With minor changes the instructions work for fink. (I have already had the ghc and ghc-bin packages) In short:

 fink install gsl
 fink install atlas
 fink install darcs
 darcs get http://perception.inf.um.es/~aruiz/darcs/hmatrix --partial
 (fink instal gnuplot)
 runhaskell Setup.lhs configure
 runhaskell Setup.lhs build
 su
 runhaskell Setup.lhs install
 exit  
 cd examples
 export LD_LIBRARY_PATH=/sw/lib/
 runhaskell tests
 OK, passed 100 tests.
 OK, passed 100 tests.
 etc.

Note that the latest version requires cabal 1.2 and the present fink version of ghc (6.6) has lower version. Nevertheless after installing cabal (which itself requires zlib and filepath) hmatrix installs without problems.