Installation 如何在(Arch)Linux x86_64上安装OCaml核心库?

Installation 如何在(Arch)Linux x86_64上安装OCaml核心库?,installation,ocaml,ocaml-core,Installation,Ocaml,Ocaml Core,在opam init期间,我对自动完成脚本问题的回答是肯定的。此外,错误的截断部分表明: 请安装camlp4的系统范围版本。这是必要的 由于您使用的是OCaml 4.02.1和系统编译器开关(该开关 使用先前存在的安装,而不是从 划痕) 如果无法安装系统范围的camlp4,则仍可使用 奥卡姆 4.02通过opam开关4.02.1 再一次 # pacman -S camlp4 $ opam install camlp4 $ opam info camlp4 package:

opam init
期间,我对自动完成脚本问题的回答是肯定的。此外,错误的截断部分表明:

请安装camlp4的系统范围版本。这是必要的 由于您使用的是OCaml 4.02.1和系统编译器开关(该开关 使用先前存在的安装,而不是从 划痕)

如果无法安装系统范围的camlp4,则仍可使用 奥卡姆 4.02通过
opam开关4.02.1

再一次

# pacman -S camlp4
$ opam install camlp4
$ opam info camlp4
            package: camlp4
            version: 4.02.1+system
         repository: default
           homepage: https://github.com/ocaml/camlp4
            license: LGPLv2
  installed-version: 4.02.1+system [system]
我需要切换到其他编译器吗

$ opam install core

#=== ERROR while installing herelib.109.35.02 =================================#
# opam-version 1.2.0
# os           linux
# command      make
# path         /home/john/.opam/system/build/herelib.109.35.02
# compiler     system (4.02.1)
# exit-code    2
# env-file     /home/john/.opam/system/build/herelib.109.35.02/herelib-31366-c61e7b.env
# stdout-file  /home/john/.opam/system/build/herelib.109.35.02/herelib-31366-c61e7b.out
# stderr-file  /home/john/.opam/system/build/herelib.109.35.02/herelib-31366-c61e7b.err
### stdout ###
# ...[truncated]
# ocamlfind ocamlopt -shared -linkall lib/herelib.cmxa -o lib/herelib.cmxs
# ocamlfind ocamldep -syntax camlp4o -package camlp4.extend -package camlp4.quotations -package camlp4.lib -modules lib/pa_here.mli > lib/pa_here.mli.depends
# ocamlfind ocamlc -c -g -syntax camlp4o -package camlp4.extend -package camlp4.quotations -package camlp4.lib -I lib -o lib/pa_here.cmi lib/pa_here.mli
# + ocamlfind ocamlc -c -g -syntax camlp4o -package camlp4.extend -package camlp4.quotations -package camlp4.lib -I lib -o lib/pa_here.cmi lib/pa_here.mli
# File "lib/pa_here.mli", line 1:
# Error: The files /usr/lib/ocaml/pervasives.cmi
#        and /usr/lib/ocaml/camlp4/Camlp4.cmi make inconsistent assumptions
#        over interface Pervasives
# Command exited with code 2.
# Makefile:21: recipe for target 'build' failed
### stderr ###
# File "setup.ml", line 232, characters 8-26:
# Warning 3: deprecated: String.set
# Use Bytes.set instead.
# File "setup.ml", line 2385, characters 6-24:
# Warning 3: deprecated: Lazy.lazy_from_fun
# Use Lazy.from_fun instead.
# E: Failure("Command ''/usr/bin/ocamlbuild' lib/herelib.cma lib/herelib.cmxa lib/herelib.a lib/herelib.cmxs lib/pa_herelib.cma lib/pa_herelib.cmxa lib/pa_here
lib.a lib/pa_herelib.cmxs -use-ocamlfind -tag debug' terminated with error code 10")
# make: *** [build] Error 1

您应该从系统编译器切换到OPAM的编译器。然后,编译器的源代码将被自动下载和编译,以及所有先决条件。要切换,请使用以下命令:

$ opam switch
system  C system  System compiler (4.02.1)
--     -- 3.11.2  Official 3.11.2 release
--     -- 3.12.1  Official 3.12.1 release
--     -- 4.00.0  Official 4.00.0 release
--     -- 4.00.1  Official 4.00.1 release
--     -- 4.01.0  Official 4.01.0 release
--     -- 4.02.0  Official 4.02.0 release
--     -- 4.02.1  Official 4.02.1 release
当然,您可以使用任何可用的编译器,而不是
4.02.1


实际的错误是,由于某种原因(我认为是由于滚动发布模型),您有不同版本的
camlp4
和OCaml编译器,因此它们无法相互通信。

我注意到camlp4包是孤立的,这是不幸的,因为它在官方存储库中。camlp4被弃用,因为它被ppx替换。它没有弃用,也没有被ppx替换。ppx和camlp4有一些交叉点,但它们是完全不同的工具。
$ opam switch
system  C system  System compiler (4.02.1)
--     -- 3.11.2  Official 3.11.2 release
--     -- 3.12.1  Official 3.12.1 release
--     -- 4.00.0  Official 4.00.0 release
--     -- 4.00.1  Official 4.00.1 release
--     -- 4.01.0  Official 4.01.0 release
--     -- 4.02.0  Official 4.02.0 release
--     -- 4.02.1  Official 4.02.1 release
opam switch 4.02.1