简体   繁体   English

将uint软件包与OCaml一起使用-opam

[英]using the uint package with OCaml - opam

I just installed opam and installed the uint package. 我刚刚安装了opam并安装了uint软件包。 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 我是OCaml和opam的新手

I used the following statement to compile the code in my OSX terminal 我使用以下语句在OSX终端中编译代码

ocaml Hello.ml 

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) Plain ocaml就像解释器一样,它不知道安装的代码在哪里(也许您习惯了python,其中解释器有很多地方是它自己先出现的)

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 假设它名为hello.ml,您可以使用

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 ) (这使用了ocamfind包装器,它为您调用ocamlc ,并告诉它使用uint包并将其链接为称为Test的最终可执行文件)

and then run it with 然后用

./Test

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM