I posted a question on the ocaml listserv that nobody responded to, I'm hoping someone here can either call me an idiot, confirm the situation, or offer up a creative solution.
When building a dynamic library through ocamlbuild I get stuck on the final linking line,
/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'
This creates an error similar to here. This error is fixed when I remove the -cc option and the -shared flag gets passed to 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 passes the -cc option to everything, so removing that isn't an option. Seems like a bug in ocamlopt; has anyone experienced similar situations? Am I
missing anything or any options in compilation?
Thanks.
EDIT
My solution is just to pass the options via a flag in myocamlbuild.ml
flag ["shared"; "link"]
(S [A"-ccopt";A"-shared"]);