我在 ocaml listserv 上发布了一个没有人回应的问题,我希望这里有人可以称我为白痴,确认情况,或提供创造性的解决方案。
通过构建动态库时,ocamlbuild
我卡在了最后的链接行上,
/opt/ocaml-3.12.1/bin/ocamlopt.opt -shared -verbose -cc gcc plugins/example.cmx -o plugins/example.cmxs -ccopt -v
+ as -o 'plugins/example.cmxs.startup.o' '/tmp/camlstartupe6993f.s'
+ gcc -o 'plugins/example.cmxs' '-L/opt/ocaml-3.12.1/lib/ocaml' -v 'plugins/example.cmxs.startup.o' 'plugins/example.o'
这会产生与此处类似的错误。当我删除-cc
选项并将-shared
标志传递给gcc
.
/opt/ocaml-3.12.1/bin/ocamlopt.opt -shared -verbose plugins/example.cmx -o plugins/example.cmxs -ccopt -v
+ as -o 'plugins/example.cmxs.startup.o' '/tmp/camlstartup2c31a2.s'
+ gcc -shared -o 'plugins/example.cmxs' '-L/opt/ocaml-3.12.1/lib/ocaml' -v 'plugins/example.cmxs.startup.o' 'plugins/example.o'
OCamlbuild 将-cc
选项传递给所有内容,因此删除它不是一个选项。似乎是 ocamlopt 中的一个错误;有没有人遇到过类似的情况?我在编译中是否遗漏了任何东西或任何选项?
谢谢。
编辑
我的解决方案只是通过 myocamlbuild.ml 中的标志传递选项
flag ["shared"; "link"]
(S [A"-ccopt";A"-shared"]);