Kylin v10sp3安装 Haskell 9.2.8
一、安装环境 Kylin v10sp3
[root@dem ~]# nkvers
############## Kylin Linux Version #################
Release:
Kylin Linux Advanced Server release V10 (Lance)
Kernel:
4.19.90-52.24.v2207.ky10.x86_64
Build:
Kylin Linux Advanced Server
release V10 (SP3) /(Lance)-x86_64-Build20/20221125
#################################################
二、下载haskell 9.2.8
下载网址:https://www.haskell.org/ghc/download_ghc_9_2_8.html#linux_x86_64
选择Centos 7的文件下载:
ghc-9.2.8-x86_64-centos7-linux.tar.xz
三、解压文档
1、xz解压
[root@dem soft]# ls -l ghc*
-rw-r–r-- 1 root root 235358772 Jun 22 09:54 ghc-9.2.8-x86_64-centos7-linux.tar.xz
[root@dem soft]# xz -d ghc-9.2.8-x86_64-centos7-linux.tar.xz
2、tar解压
[root@dem soft]# tar -xvf ghc-9.2.8-x86_64-centos7-linux.tar
ghc-9.2.8/bindist.mk
ghc-9.2.8/compiler/ghc.cabal
ghc-9.2.8/compiler/ghc.mk
ghc-9.2.8/compiler/./HsVersions.h
ghc-9.2.8/compiler/LICENSE
ghc-9.2.8/compiler/stage1/build/.depend-v.c_asm
ghc-9.2.8/compiler/stage1/build/.depend-v.haskell
ghc-9.2.8/compiler/stage1/package-data.mk
ghc-9.2.8/compiler/stage2/build/.depend-v-p-dyn.c_asm
ghc-9.2.8/compiler/stage2/build/.depend-v-p-dyn.haskell
。。。
ghc-9.2.8/utils/runghc/ghc.mk
ghc-9.2.8/utils/runghc/runghc.wrapper
ghc-9.2.8/utils/testremove/ghc.mk
ghc-9.2.8/utils/unlit/dist/build/.depend.c_asm
ghc-9.2.8/utils/unlit/dist-install/build/.depend.c_asm
ghc-9.2.8/utils/unlit/dist-install/build/tmp/unlit
ghc-9.2.8/utils/unlit/ghc.mk
四、安装
1、configure
[root@dem soft]# cd ghc-9.2.8/
[root@dem ghc-9.2.8]# ls
bindist.mk config.guess configure driver ghc.mk inplace install-sh libraries llvm-passes Makefile packages rts utils
compiler config.sub docs ghc includes INSTALL libffi LICENSE llvm-targets mk README rules
[root@dem ghc-9.2.8]# ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
Build platform inferred as: x86_64-unknown-linux
Host platform inferred as: x86_64-unknown-linux
Target platform inferred as: x86_64-unknown-linux
GHC build : x86_64-unknown-linux
GHC host : x86_64-unknown-linux
GHC target : x86_64-unknown-linux
LLVM target: x86_64-unknown-linux
。。。
config.status: creating mk/config.mk
config.status: creating mk/install.mk
****************************************************
Configuration done, ready to 'make install'
(see README and INSTALL files for more info.)
****************************************************
2、install
[root@dem ghc-9.2.8]# make install
make --no-print-directory -f ghc.mk install BINDIST=YES NO_INCLUDE_DEPS=YES
"rm" -f libraries/ghc-boot/dist-install/build/GHC/Version.hs
done.
"rm" -f libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs
done.
"inplace/bin/mkdirhier" libraries/ghc-boot/dist-boot/build/GHC//.
"rm" -f libraries/ghc-boot/dist-boot/build/GHC/Version.hs
done.
"inplace/bin/mkdirhier" libraries/ghc-boot/dist-boot/build/GHC/Platform//.
"rm" -f libraries/ghc-boot/dist-boot/build/GHC/Platform/Host.hs
done.
/usr/bin/install -c -m 755 -d "/usr/local/bin"
。。。
/usr/bin/install -c -m 755 -d "/usr/local/bin"
/usr/bin/install -c -m 755 -d "/usr/local/share/doc/ghc-9.2.8"
/usr/bin/install -c -m 755 -d "/usr/local/share/doc/ghc-9.2.8/html"
/usr/bin/install -c -m 644 docs/index.html "/usr/local/share/doc/ghc-9.2.8/html"
/usr/bin/install -c -m 755 -d "/usr/local/share/doc/ghc-9.2.8/html/libraries"
for i in libraries/dist-haddock/*; do \
/usr/bin/install -c -m 644 $i "/usr/local/share/doc/ghc-9.2.8/html/libraries/"; \
done
/usr/bin/install -c -m 644 libraries/prologue.txt "/usr/local/share/doc/ghc-9.2.8/html/libraries/"
/usr/bin/install -c -m 755 libraries/gen_contents_index "/usr/local/share/doc/ghc-9.2.8/html/libraries/"
五、运行
1、初次运行告警libgmp.so 不存在
初次运行gchi出现警告信息:libgmp.so 不存在
[root@dem ghc-9.2.8]# ghci
GHCi, version 9.2.8: https://www.haskell.org/ghc/ :? for help
<no location info>: warning: [-Wmissed-extra-shared-lib]
libgmp.so: cannot open shared object file: No such file or directory
It's OK if you don't want to use symbols from it directly.
(the package DLL is loaded by the system linker
which manages dependencies by itself).
ghci>
2、libgmp.so 不存在 解决方案:
[root@dem ghc-9.2.8]# cd /usr/lib64
[root@dem lib64]# ls -l libgmp*
lrwxrwxrwx 1 root root 16 Dec 24 2021 libgmp.so.10 -> libgmp.so.10.4.0
-rwxr-xr-x 1 root root 514096 Dec 24 2021 libgmp.so.10.4.0
[root@dem lib64]# ln -s libgmp.so.10 libgmp.so
[root@dem lib64]# ls -l libgmp*
lrwxrwxrwx 1 root root 12 Jun 22 10:41 libgmp.so -> libgmp.so.10
lrwxrwxrwx 1 root root 16 Dec 24 2021 libgmp.so.10 -> libgmp.so.10.4.0
-rwxr-xr-x 1 root root 514096 Dec 24 2021 libgmp.so.10.4.0
3、交互运行小实例(求100以内勾股数)
定义函数 : pyths n = [(x, y, z) | x <- m,y <- m, z <- m,x^2 + y^2 == z^2 where m = [1…n]
执行行数 : pyths 100
[root@dem lib64]# ghci
GHCi, version 9.2.8: https://www.haskell.org/ghc/ :? for help
ghci> pyths n = [(x, y, z) | x <- m,y <- m, z <- m, x^2 + y^2 == z^2 ] where m = [1..n]
ghci> pyths 100
[(3,4,5),(4,3,5),(5,12,13),(6,8,10),(7,24,25),(8,6,10),(8,15,17),(9,12,15),(9,40,41),(10,24,26),(11,60,61),(12,5,13),(12,9,15),(12,16,20),(12,35,37),(13,84,85),(14,48,50),(15,8,17),(15,20,25),(15,36,39),(16,12,20),(16,30,34),(16,63,65),(18,24,30),(18,80,82),(20,15,25),(20,21,29),(20,48,52),(21,20,29),(21,28,35),(21,72,75),(24,7,25),(24,10,26),(24,18,30),(24,32,40),(24,45,51),(24,70,74),(25,60,65),(27,36,45),(28,21,35),(28,45,53),(28,96,100),(30,16,34),(30,40,50),(30,72,78),(32,24,40),(32,60,68),(33,44,55),(33,56,65),(35,12,37),(35,84,91),(36,15,39),(36,27,45),(36,48,60),(36,77,85),(39,52,65),(39,80,89),(40,9,41),(40,30,50),(40,42,58),(40,75,85),(42,40,58),(42,56,70),(44,33,55),(45,24,51),(45,28,53),(45,60,75),(48,14,50),(48,20,52),(48,36,60),(48,55,73),(48,64,80),(51,68,85),(52,39,65),(54,72,90),(55,48,73),(56,33,65),(56,42,70),(57,76,95),(60,11,61),(60,25,65),(60,32,68),(60,45,75),(60,63,87),(60,80,100),(63,16,65),(63,60,87),(64,48,80),(65,72,97),(68,51,85),(70,24,74),(72,21,75),(72,30,78),(72,54,90),(72,65,97),(75,40,85),(76,57,95),(77,36,85),(80,18,82),(80,39,89),(80,60,100),(84,13,85),(84,35,91),(96,28,100)]
验证一组值:
ghci> 96*96+28*28
10000
4、编译运行helloword.hs
[root@dem tcode]# cat helloworld.hs
module Main where
main = putStrLn "Hello, World!"
[root@dem tcode]# ghc helloworld.hs
[1 of 1] Compiling Main ( helloworld.hs, helloworld.o )
Linking helloworld ...
[root@dem tcode]# ls
helloworld helloworld.hi helloworld.hs helloworld.o
[root@dem tcode]# ./helloworld
Hello, World!