shiyeon7
shiyeon7

Reputation: 1

OCaml: Installing a library?

I'm a complete noob in OCaml and I am attempting to use libraries for the first time. I'm attempting to use this library: https://github.com/savonet/ocaml-mm and trying to run the examples that were listed in the repository. It's not exactly compiling correctly so I believe I may have installed it incorrectly?

These are the steps I took in installing this package:

1). git clone https://github.com/savonet/ocaml-mm.git 2). cd ocaml-mm 3). opam pin add .

This returned:

The following actions will be performed:
  ↗ upgrade   mm         0.7.4 to 0.8.0*
  ↻ recompile liquidsoap 2.0.3-1         [uses mm]
===== ↻ 1   ↗ 1 =====
Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[liquidsoap.2.0.3-1] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⊘ removed   liquidsoap.2.0.3-1
⊘ removed   mm.0.7.4
∗ installed mm.0.8.0
[ERROR] The compilation of liquidsoap failed at "/usr/bin/make".

#=== ERROR while compiling liquidsoap.2.0.3-1 =================================#
# context     2.0.5 | linux/x86_64 | ocaml-base-compiler.4.12.0 | https://opam.ocaml.org#1c609c75
# path        ~/.opam/cs3110-2022sp/.opam-switch/build/liquidsoap.2.0.3-1
# command     /usr/bin/make
# exit-code   2
# env-file    ~/.opam/log/liquidsoap-9751-e4f8df.env
# output-file ~/.opam/log/liquidsoap-9751-e4f8df.out
### output ###
# [...]
# OCAMLOPT -c stream/frame_content.mli
# OCAMLOPT -c stream/frame_content.ml
# File "stream/frame_content.ml", line 372, characters 10-43:
# 372 |           (Audio.Mono.sub a' !dst_pos !len))
#                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Error: This expression has type Mm.Audio.Mono.t = float array
#        but an expression was expected of type int
# make[2]: *** [../Makefile.rules:122: stream/frame_content.cmx] Error 2
# make[2]: Leaving directory '/home/ddavidjeong/.opam/cs3110-2022sp/.opam-switch/build/liquidsoap.2.0.3-1/src'
# make[1]: *** [../Makefile.rules:69: all-auto-ocaml-prog] Error 2
# make[1]: Leaving directory '/home/ddavidjeong/.opam/cs3110-2022sp/.opam-switch/build/liquidsoap.2.0.3-1/src'
# make: *** [Makefile.rules:29: all-subdirs] Error 2



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build liquidsoap 2.0.3-1
└─
┌─ The following changes have been performed
│ ⊘ remove  liquidsoap 2.0.3-1
│ ↗ upgrade mm         0.7.4 to 0.8.0
└─

<><> liquidsoap.2.0.3-1 troubleshooting <><><><><><><><><><><><><><><><><><><><>
=> We're sorry that your liquidsoap install failed. Check out our installation
   instructions at: https://www.liquidsoap.info/doc-2.0.3-1/install.html#opam
   for more information.
[NOTE] Pinning command successful, but your installed packages may be out of sync.

The former state can be restored with:
    opam switch import "/home/ddavidjeong/.opam/cs3110-2022sp/.opam-switch/backup/state-20220316072305.export"
Or you can retry to install your package selection with:
    opam install --restore

I thought this still mean the ocaml-mm library was installed since liquidsoap was a previous library I was fumbling with and it only recompiled that library.

Now when I attempt to compile the library code in VS, the modules in the example when being opened are unbounded and none of the examples compile.

I'm thinking that I either installed it incorrectly or I'm just using libraries completely wrong.

Upvotes: 0

Views: 1208

Answers (1)

octachron
octachron

Reputation: 18912

First, if you don't need the development version of the mm library, you can simply use

opam install mm

rather than cloning by hand the mm git repository. Even, if you need the development version, you can ask opam to install it directly with

opam pin add --dev-repo mm

Second, when you say that none of the example compile, do you mean when you call make in the example directory of the library? Or are you trying to compile an example file directly?

If it is the second option, you are probably missing the library dependency in your dune file (do you have a dune file?). Typically, the dune file for the drums example in the mm library repo is:

(executable
 (name drums)
 (modules drums)
 (optional)
 (libraries mm.audio mm.oss))

One last potential issue is that you will need to launch one build of the example for the dependencies to be registred in your editor.

Upvotes: 4

Related Questions