mac ocaml build的未定义符号

时间:2014-03-27 00:21:24

标签: macos ocaml ctypes libffi

我一直在尝试编译最近使用ctypessqlexpr的应用程序,但我遇到了无法解析符号的问题。我从OPAM构建了ctypes和sqlexpr,并且已经从brew更新了libffi的版本,但是不明白为什么我可能没有获得正确的库链接。有人在乎猜猜吗? (我已经尝试过我的典型修复方法,即传递CFLAGS="-arch i386"

Undefined symbols for architecture x86_64:
  "_ffi_closure_alloc", referenced from:
      _ctypes_make_function_pointer in libctypes-foreign-base_stubs.a(ffi_call_stubs.o)
  "_ffi_prep_closure_loc", referenced from:
      _ctypes_make_function_pointer in libctypes-foreign-base_stubs.a(ffi_call_stubs.o)
  "_sqlite3_enable_load_extension", referenced from:
      _caml_sqlite3_enable_load_extension in libsqlite3_stubs.a(sqlite3_stubs.o)
     (maybe you meant: _caml_sqlite3_enable_load_extension)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
File "_none_", line 1:
Error: Error while building custom runtime system
Command exited with code 2.
Compilation unsuccessful after building 41 targets (40 cached) in 00:00:00.
make: *** [all] Error 10

2 个答案:

答案 0 :(得分:1)

来自https://github.com/ocaml/opam-repository/issues/398,看起来这是Mac OS X 10.7.5上sqlite的问题。

  

"切换指定包的顺序可以解决问题"

答案 1 :(得分:0)

要回答这个问题,我采用了Thomas Leonard的解决方案,并且还必须在我的mac上安装新版本的libffi。我必须在brew中强制使用libffi链接,并删除libffi/usr/lib/libffi.dylib的版本,然后将其指向我在brew的酒窖中的版本。完成这些操作后,随着切换OCamlBuild软件包订单,一切顺利完成。