2016-09-26 17 views
0

我升級我的ocaml到4.03.0。 然後,一些包裝庫無法生成「沒有提供實現」錯誤。在OCaml 4.03.0 FFI無法編譯與「沒有實現提供」錯誤

我準備一個小例子來解釋我的情況。

我寫在hello_stubs.c

#include<stdio.h> 
#include<caml/mlvalues.h> 
CAMLprim value caml_print_hello(value unit) 
{ 
    printf("Hello\n"); 
    return Val_unit; 
} 

接着一個C代碼,我製備接口文件爲ocaml的,在hello.mli

external print_hello : unit -> unit = "caml_print_hello" 

然後,我在main.ml

Hello.print_hello();; 

編碼一個主程序要編譯這些程序,我執行以下命令。

ocamlc -c hello.mli 
ocamlc -c hello_stubs.c 
ocamlopt -o main main.ml hello_stubs.o 

然後,不幸的是,最後一個命令失敗,出現以下錯誤消息。

File "_none_", line 1: 
Warning 58: no cmx file was found in path for module Hello, and its interface was not compiled with -opaque 
File "main.ml", line 1: 
Error: No implementations provided for the following modules: 
     Hello referenced from main.cmx 

據消息, 我試過ocamlc -opaque hello.mli,但它並沒有解決問題。

我也確認上述命令對於ocaml 4.02.3工作正常。

你知道如何用ocaml 4.03.0編譯這個例子嗎?

回答

2

修復很簡單:創建hello.mlhello.mli相同的內容並編譯並鏈接main

我想這是由於4.03.0以下變化:

  • PR#4166,PR#6956:力調用外部C原語 連接時(雅克常綠矮灌木叢,由馬庫斯Mottl和Christophe報告Troestler)

參考手冊的相關章節應該更新。見http://caml.inria.fr/mantis/view.php?id=7371

相關問題