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
。如何正确链接库和驱动程序文件?