1

I just installed opam and installed the uint package. However when I attempt to do something like this

File : Hello.ml
let ash(mystring) = (
    let basis =   uint64.of_string("0xcbf29ce484221325") in
    Printf.printf "Function Finished" ;
);;

ash("Hello");;

I get the error

Error: Unbound value uint64

Any suggestions on what I could be missing ? I am new to OCaml and opam

I used the following statement to compile the code in my OSX terminal

ocaml Hello.ml 
James Franco
  • 4,516
  • 10
  • 38
  • 80

1 Answers1

1

Few issues, you don't need the () around arguments unless you intend them to be a tuple of values (Perhaps a topic you'll learn later down the road)

Plain ocaml is just like an interpreter, it doesn't know where installed code is (Perhaps you're used to like python where the interpreter has a few places that it looks on its own first)

let ash mystring =
  let basis = Uint64.of_string "0xcbf29ce484221325" in
  Printf.printf "Function Finished"

let () =
  ash "Hello"

Assuming that is called hello.ml, you can compile it with

ocamlfind ocamlc -package uint -linkpkg hello.ml -o Test

(This is using the ocamfind wrapper and it calls ocamlc for you and tells it to use the uint package and link it for the final executable called Test)

and then run it with

./Test
  • @JamesFranco `opam install ocamlfind` –  Sep 20 '15 at 20:21
  • It says.` [NOTE] Package ocamlfind is already installed (current version is 1.5.5)` . I am a little confused as to why it cant find it. Do I need to set it up in the environment variables ? – James Franco Sep 20 '15 at 20:23
  • Open new shell/terminal, do `eval \`opam config env\`` Then check if ocamlfind is present, `which ocamlfind` –  Sep 20 '15 at 20:24
  • Thanks that did the trick - looks like I needed to do `eval \`opam config env\`` – James Franco Sep 20 '15 at 20:28
  • 1
    @JamesFranco No problem, if you're curious later you can read this answer that delves a little deeper in OCaml toolchain, http://stackoverflow.com/questions/30543465/function-applied-to-too-many-arguments-in-lablgtk/30606309#30606309 –  Sep 20 '15 at 20:31