Install Haskell on Ubuntu and CentOS

时间:2023-12-30 12:26:44

For Ubuntu:

Step one: Install GHC

If you don't want to install curl you can skip step 1 and just directly download ghc package.

1. Install curl first.

sudo apt-get install gcc libgmp3-dev curl

2.Make a directory to get the ghc package.

For 64 bit machine, get the following package:

cabal update
curl -O http://www.haskell.org/ghc/dist/7.6.3/ghc-7.6.3-x86_64-unknown-linux.tar.bz2

For 32 bit machine, get the following package:

curl -O http://www.haskell.org/ghc/dist/7.6.3/ghc-7.6.3-i386-unknown-linux.tar.bz2

3. Decompress the tar package and install GHC, before doing that install some lib.

sudo apt-get install libgmp3-dev

sudo apt-get install libgmp3c2

tar -xjvf ghc-7.6.3-x86_64-unknown-linux.tar.bz2 or tar -xjvf ghc-7.6.3-i386-unknown-linux.tar.bz2

cd ghc-7.6.3
./configure
sudo make install

4. Check the version.

ghc --version

If it is ok, you will see:

The Glorious Glasgow Haskell Compilation System, version 7.6.3

Step two : Install Haskell Platform

1. Download the package first.

curl -O http://lambda.haskell.org/platform/download/2013.2.0.0/haskell-platform-2013.2.0.0.tar.gz
tar -xf haskell-platform-2013.2.0.0.tar.gz

2. Install the following package:

sudo apt-get install libglc-dev
sudo apt-get install freeglut3-dev

3. cd to haskell-platform-2013.2.0.0

./configure

sudo make

sudo make install

4. Last it will suggest you to Use "cabal install <foo>" to install additional packages, just update cabal

cabal update

That's done.

For CentOS:

It is almost the same as ubuntu except some places to notice.
Step one: Install GHC
1. Directly download the GHC tar and extract it to a folder.
cd ghc-7.6.3
./configure
sudo make install
</pre><pre code_snippet_id="370751" snippet_file_name="blog_20140530_14_1907562" name="code" class="plain">ghc --version

It is the same as before.

Step two : Install Haskell Platform
1. Directly downlaod haskell-platform-2013.2.0.0.tar.gz and extract it to a folder.
When run configure, it will get error that can't find some lib files like The zlib C library is required. 
I search a lot and even I download the zlib and installed manually can't resolve this problem.
Finally I find a solution, just install the following:
yum install gmp gmp-devel freeglut freeglut-devel libX11-devel mesa-libGLU-devel zlib-devel

It will resolve the issue. That's great.

Then run the following as before, it will install haskell platform successfully.
./configure

sudo make

sudo make install

cabal update

Reference:

http://powman.org/archives/haskell_env.html

http://tryhaskell.org/