2016-07-24 44 views
4

我有一个使用Str模块的OCaml的项目,但在编译的时候,我得到这个错误:提供了以下模块没有实现:力量

$ make        
ocaml setup.ml -build              
Finished, 0 targets (0 cached) in 00:00:00. 
+ /home/phase/.opam/system/bin/ocamlfind ocamlopt -g -linkpkg src/objects.cmx src/golf.cmx -o src/golf.native 
File "_none_", line 1:             
Error: No implementations provided for the following modules:    
     Str referenced from src/golf.cmx         
Command exited with code 2. 
Compilation unsuccessful after building 7 targets (6 cached) in 00:00:00. 
E: Failure("Command ''/usr/bin/ocamlbuild' src/golf.native -tag debug' terminated with error code 10") 
Makefile:7: recipe for target 'build' failed 
make: *** [build] Error 1 

这是一个绿洲项目具有以下_oasis文件:

Name: GolfCaml 
Version: 0.0.0 
Synopsis: GolfScript Interpreter in OCaml 
Authors: Jadon Fowler <[email protected]> 
License: https://www.mozilla.org/en-US/MPL/2.0/ 

Description: GolfCaml is an interpreter for GolfScript in OCaml. 
Homepage: http://jadonfowler.xyz/ 

OASISFormat: 0.4 
BuildTools: ocamlbuild 
Plugins: META (0.4), DevFiles (0.4) 

Executable "golfcaml" 
    Path: src 
    MainIs: golf.ml 
    CompiledObject: best 

这里是有问题的代码:

(* Token Regex from http://www.golfscript.com/golfscript/syntax.html *) 
let token_regex = Str.regexp "[a-zA-Z_][a-zA-Z0-9_]*|'(?:\\.|[^'])*'?|\"(?:\\.|[^\"])*\"?|-?[0-9]+|#[^\n\r]*|." 

(* Iterate of a line and interpret each char *) 
let interpret_line line = 
    let tokens = Str.split token_regex line in 
    List.iter (fun (x) -> printf "%s\n" x) tokens 

回答

6

你几乎已经;-)

Str不在标准库中,所以你需要告诉oasis采取它。在你_oasis文件只需添加一件事你Executable部分:

_oasis

Executable "golfcaml" 
    Path: src 
    MainIs: golf.ml 
    CompiledObject: best 
    BuildDepends: 
    str 

而且它将很好地工作:

make 
ocaml setup.ml -build 
Finished, 0 targets (0 cached) in 00:00:00. 
Finished, 4 targets (0 cached) in 00:00:00. 
相关问题