mirage / checkseum

MIT License
15 stars 13 forks source link

I'm not able to use Checkseum #36

Closed ttamttam closed 4 years ago

ttamttam commented 4 years ago

Hello,

while trying to use git-unix from utop, I'm obtaining: Error: Reference to undefined global `Checkseum'

I then tried directly with Checkseum, and obtained the same message. Unfortunately, I'm not sure what to check now? Do you have any idea?

$ utop -require checkseum

utop # Checkseum.Crc32.digest_bigstring;;
Line 1:
Error: Reference to undefined global `Checkseum'
─( 17:45:38 )─< command 1 >────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─

Here are some more informations:

$ opam --version
2.0.5
$ opam switch
#  switch          compiler                       description
→  4.08.1          ocaml-base-compiler.4.08.1     4.08.1
$ opam show checkseum

<><> checkseum: information on all versions <><><><><><><><><><><><><><><><><><>
name                   checkseum
all-installed-versions 0.1.1 [4.08.1]
all-versions           0.0.1  0.0.2  0.0.3  0.0.9  0.1.0  0.1.1

<><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><><><>
version       0.1.1
repository    default
url.src:      "https://github.com/mirage/checkseum/releases/download/v0.1.1/checkseum-v0.1.1.tbz"
url.checksum: "sha256=a3913487f951c5bebc8e44cce41878ef3e2263c9c81a1ed963b0a86268c84229"
              "sha512=f97c2e353c2bebdef2ed61cc6a32994fc9028c70e8c96b134ea92d178a29e2eda6c8bad1099b0a6d05971a69c94da2d5d476aeb4ddd9e802bb4bebe07f034579"
homepage:     "https://github.com/mirage/checkseum"
bug-reports:  "https://github.com/mirage/checkseum/issues"
dev-repo:     "git+https://github.com/mirage/checkseum.git"
authors:      "Romain Calascibetta <romain.calascibetta@gmail.com>"
maintainer:   "Romain Calascibetta <romain.calascibetta@gmail.com>"
license:      "MIT"
depends:      "ocaml" {>= "4.07.0"}
              "dune" {>= "1.9.2"}
              "optint" {>= "0.0.3"}
              "base-bytes"
              "bigarray-compat"
              "fmt"
              "rresult"
              "cmdliner"
              "alcotest" {with-test}
depopts:      "ocaml-freestanding" "mirage-xen-posix"
conflicts:    "mirage-xen-posix" {< "3.1.0"}
              "ocaml-freestanding" {< "0.4.3"}
              "mirage-runtime" {< "4.0.0"}
synopsis      Adler-32, CRC32 and CRC32-C implementation in C and OCaml
description   Checkseum is a library to provide implementation of Adler-32, CRC32 and CRC32-C in C and OCaml.
              This library use the linking trick to choose between the C implementation (checkseum.c) or the OCaml implementation (checkseum.ocaml).
              This library is on top of optint to get the best representation of an int32.
dinosaure commented 4 years ago

Hi,

So, checkseum uses variants/linking-trick to be able to provide a C implementation and an OCaml implementation (as digestif). By this way, the virtual package checkseum does not have a proper implementation as expected and just provide an interface - and it's why you are able to see Checkseum in utop.

To be able to fully use checkseum with utop, you need to specify which implementation you want, so you need to write:

$ utop -require checkseum.c

or

$ utop -require checkseum.ocaml

Note that if you are into a dune environment and you write a library or an executable, dune will be able (with checkseum.1.0.0 at least) to choose the default implementation checkseum.c. So, dune utop in your library workspace or dune build in your executable workspace will silently links with checkseum.c. If you want to use checkseum.ocaml (for example if you want to use js_of_ocaml), you can explicitly specify checkseum.ocaml as a dependence of your executable (note that you are not able to explicitly choose the implementation for a library).

So for any others libraries like git-unix, you have the same problem where you need to choose which implementation you want at first (like utop -require checkseum.c,digestif). But, again, if you want to make a project with git-unix and dune as your build-system, you should not find any trouble :+1:.

I hope, this response is clear for you. I know that this kind of design is not very easy to understand but for many purpose (like irmin with Javascript), it serves many use-cases. And as a MirageOS project, we mostly want to be platform agnostic.

dinosaure commented 4 years ago

I updated the README.md, so I close the issue where documentation about thiat can be found :+1:.

ttamttam commented 4 years ago

I updated the README.md, so I close the issue where documentation about thiat can be found +1.

Merci ! En plus, je n’ai même pas eu le temps de proposer un PR pour adapter le README !