On 09/14/2011 05:56 PM, Romain Bardou wrote:
> [...]
>     ocamlopt -c -ccopt -fPIC wrapper.c
>     ocamlopt -c mylib.ml
>     ocamlmklib wrapper.o mylib.cmx -o mylib
>     ocamlopt -c main.ml
>     ocamlopt dynlink.cmxa main.cmx -o main
>     CAML_LD_LIBRARY_PATH=. ./main mylib.cmxa
> 
> But when Dynlink.load is called, it fails with the following error:
> 
>     error loading shared library: /home/.../mylib.cmxa: invalid ELF header
> 
> I'm thinking this is because the .cmxa has not been compiled with the
> -shared option, but I don't know how to tell ocamlmklib to compile with
> the -shared option.

You can turn the .cmxa generated by ocamlmklib into a .cmxs by calling
(for example):

  ocamlopt -shared -I . -linkall -o mylib.cmxs mylib.cmxa

The .cmxs should then be loadable by Dynlink.load.


Cheers,

-- 
Stéphane

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to