一、open Core.Std 时报Unbound module Core
先安装库html
$ opam init $ opam install core $ opam install utop
在~/.ocamlinit头部添加下面代码函数
#use "topfind" #camlp4o #thread #require "core.top" #require "core.syntax"
到这里后仍是不行,后来想起系统好久没关机了,重启了一下系统就一切OK了ui
二、调试
ocamlopt编译的是native程序,ocamlc -g编译出的是带调试信息的字节码程序,使用ocamldebug能够调试它
调试命令debug
命令 | 说明 |
---|---|
run | 运行 |
reverse | 反向运行 .... |
step [count] | 单步,进入函数调用 |
backstep [count] | 回退一步,进入函数调用 |
next [count] | 单步,跳过函数调用 |
previous [count] | 回退,跳过函数调用 |
finish | 运行直到当前函数返回 |
start | 反向运行直到函数开始位置 |
kill | 结束程序执行 |
break function | |
break @main 94 | 在main.ml的94行下断点 |
break @ [module] # character | |
info breakpoints | 显示全部断点 |
delete [breakpoint-numbers] | 删除断点。注意:若是没有参数,全部断点都被删除 |
backtrace [count], bt [count] | 栈回溯 |
frame | 当前栈 |
print variables | |
display variables |
命令能够只写一部分,好比s表明step,n表明next
更多命令请看:
https://caml.inria.fr/pub/docs/manual-ocaml/debugger.html#sec388调试