Library not found

I have the sequence below which I synthesize as :

I have installed the library stdint
I have added Stdint in my dune file :

(executable
 (public_name Bataille)
 (name main)
 (libraries Bataille ANSITerminal Stdint))

and when I build my programm, dune does not find Stdint …

Help appreciated (again).

PS H:\OCaml\Bataille> opam show stdint

<><> stdint: information on all versions ><><><><><><><><><><><><><><><><><><><>
name                   stdint
all-installed-versions 0.7.2 [playground]
all-versions           0.3.0-0  0.4.0  0.4.1  0.4.2  0.5.0  0.5.1  0.6.0  0.7.0  0.7.1  0.7.2

<><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><><><>
version      0.7.2
repository   fdopen-mingw-1.2.0-4.14.0
url.src      "https://github.com/andrenth/ocaml-stdint/releases/download/0.7.2/stdint-0.7.2.tbz"
url.checksum "sha256=1560198d8bc9c7af3ea952c40dabe82666694210ecc3fdf9bbfeb43211e977e6"
             "sha512=b0319c2e7490e58effc7a01f2c5635d3468e501741478249e012dda039729609f7bb7d3cb6239eed709f1c043bc23a1c6cff777b174d215fbf6f2eba9f0d023d"
homepage     "https://github.com/andrenth/ocaml-stdint"
doc          "https://andrenth.github.io/ocaml-stdint/"
bug-reports  "https://github.com/andrenth/ocaml-stdint/issues"
authors      "Andre Nathan <andre@digirati.com.br>"
             "Markus W. Weissmann <markus.weissmann@in.tum.de>"
maintainer   "Markus W. Weissmann <markus.weissmann@in.tum.de>"
license      "MIT"
depends      "dune" {>= "3.0"} "ocaml" {>= "4.03"} "qcheck" {with-test} "odoc" {with-doc}
synopsis     Signed and unsigned integer types having specified widths
description  The stdint library provides signed and unsigned integer types of various fixed
             widths: 8, 16, 24, 32, 40, 48, 56, 64 and 128 bit.
             This interface is similar to Int32 and Int64 from the base library but provides
             more functions and constants like arithmetic and bit-wise operations, constants
             like maximum and minimum values, infix operators conversion to and from every
             other integer type (including int, float and nativeint), parsing from and
             conversion to readable strings (binary, octal, decimal, hexademical), conversion
             to and from buffers in both big endian and little endian byte order.
PS H:\OCaml\Bataille> dune --version
3.6.2
PS H:\OCaml\Bataille> ocaml --version
The OCaml toplevel, version 4.14.0
PS H:\OCaml\Bataille> dune build
File "bin/dune", line 4, characters 34-40:
4 |  (libraries Bataille ANSITerminal Stdint))
                                      ^^^^^^
Error: Library "Stdint" not found.
-> required by _build/default/bin/main.exe
-> required by _build/install/default/bin/Bataille.exe
-> required by _build/default/Bataille.install
-> required by alias all
-> required by alias default
File "bin/Bataille.ml", line 75, characters 27-28:
75 |    s.nb_parties <- Uint8.+ s.nb_parties one;
                                ^
Error: Syntax error

The library is called stdint not Stdint. If you need to lookup library names have a look at ocamlfind list.

Was just coming here to say that. But also, the way I learned it (b/c I’m not a dune user at all).

  1. look up the stdint github repo
  2. look at their tests
  3. they use dune!
  4. https://github.com/andrenth/ocaml-stdint/blob/master/tests/dune
(test
 (name stdint_test)
 (libraries str stdint qcheck)
 (flags (:standard -w -32)))

Well-written packages come with copious tests, and you (I also) can look at those tests to see how to use 'em.

1 Like

Thank you all for your replies. Nevertheless, this did not solve my issue though. Ocamlfind did find the stdint library (in lowercase) and the correct version:

PS H:\OCaml\Bataille> (& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }
PS H:\OCaml\Bataille> dune build
File "bin/dune", line 4, characters 34-39:
4 |  (libraries Bataille ANSITerminal sdint))
                                      ^^^^^
Error: Library "sdint" not found.
-> required by _build/default/bin/main.exe
-> required by _build/install/default/bin/Bataille.exe
-> required by _build/default/Bataille.install
-> required by alias all
-> required by alias default
File "bin/Bataille.ml", line 75, characters 27-28:
75 |    s.nb_parties <- Uint8.+ s.nb_parties one;
                                ^
Error: Syntax error

stdint :–)

Other than that you really have a syntax error in Bataille.ml, Uint8.+ is not valid syntax. Maybe you meant Uint8.( + ) if there’s such an operator in the Uint8 module.

1 Like

I hate asking questions for that kind of error. I was sure I tried with “stdint” before asking here …

Thanks, and yes, I had a typo for which I did not know the exact spelling. solved now.

As Boileau used to say : go back to your work again

1 Like