4
我編譯了一個實現FFI作爲(.so)動態庫的Haskell源代碼包。我想調用OCaml中通過FFI導出的函數。爲此,我實現了一個簡單的驅動程序文件如下將OCaml代碼與共享庫連接起來
open Quelea.Shim
open Ctypes
open PosixTypes
open Foreign
let readEffects =
foreign "readEffects" (ptr char @-> ptr char @-> returning ptr string)
let effects = readEffects "csasc" "saxasxas"
print_list effects
let rec print_list = function
[] ->()
| e::l -> print_int e ; print_string " " ; print_list l
凡readEffects是一個函數通過FFI出口具有以下簽名
foreign export ccall readEffects :: CString -> CString -> IO (Ptr CString)
我試圖編譯哈斯克爾源的Quelea.Shim模塊如上述(main.ml)文件如下
ocamlc -dllpath /home/parallels/.cabal/lib/Quelea-0.0.1/ghc-7.6.3 main.ml
目錄/home/parallels/.cabal/lib/Quelea-0.0.1/ghc-7.6.3
包含庫文件libHSQuelea-0.0.1-ghc7.6.3.so
。
我收到錯誤Error: Unbound module Quelea
。如何正確鏈接庫和驅動程序文件?