* Embedding OCaml - manual not up to date.
@ 2010-02-16 21:45 Guillaume Yziquel
2010-02-16 22:35 ` Guillaume Yziquel
0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Yziquel @ 2010-02-16 21:45 UTC (permalink / raw)
To: OCaml List
Hi.
The manual is not up to date when it comes to embedding OCaml code into
C code.
http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html#toc134
Specifically the section
18.7.5 Embedding the Caml code in the C code
and the piece of compilation code I'm having trouble with is the following:
> ocamlopt -output-obj -o camlcode.o unix.cmxa other .cmx and .cmxa files
> cc -o myprog C objects and libraries \
> camlcode.o -L/usr/local/lib/ocaml -lunix -lasmrun
This code complains about missing symbols from pervasives.
So I adapt it by compiling with pervasives.cmx, and I get
> ocamlopt -output-obj -o camlcode.o pervasives.cmx
> ld: /usr/lib/ocaml/pervasives.o: No such file: No such file or directory
> File "caml_startup", line 1, characters 0-1:
> Error: Error during linking
> make: *** [camlcode.o] Erreur
But I cannot find pervasives.o anywhere.
--
Guillaume Yziquel
http://yziquel.homelinux.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Embedding OCaml - manual not up to date.
2010-02-16 21:45 Embedding OCaml - manual not up to date Guillaume Yziquel
@ 2010-02-16 22:35 ` Guillaume Yziquel
0 siblings, 0 replies; 2+ messages in thread
From: Guillaume Yziquel @ 2010-02-16 22:35 UTC (permalink / raw)
To: OCaml List
Guillaume Yziquel a écrit :
> Hi.
>
> The manual is not up to date when it comes to embedding OCaml code into
> C code.
>
> http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html#toc134
>
> Specifically the section
>
> 18.7.5 Embedding the Caml code in the C code
>
> and the piece of compilation code I'm having trouble with is the following:
>
>> ocamlopt -output-obj -o camlcode.o unix.cmxa other .cmx and
>> .cmxa files
>> cc -o myprog C objects and libraries \
>> camlcode.o -L/usr/local/lib/ocaml -lunix -lasmrun
>
> This code complains about missing symbols from pervasives.
>
> So I adapt it by compiling with pervasives.cmx, and I get
>
>> ocamlopt -output-obj -o camlcode.o pervasives.cmx
>> ld: /usr/lib/ocaml/pervasives.o: No such file: No such file or directory
>> File "caml_startup", line 1, characters 0-1:
>> Error: Error during linking
>> make: *** [camlcode.o] Erreur
>
> But I cannot find pervasives.o anywhere.
Well I found it in stdlib.a, but looking back at the thread started by
Aaron Bohannon mid-december
http://caml.inria.fr/pub/ml-archives/caml-list/2009/12/3375527140f0de987a9dc6d2553990c8.en.html
it seems to me that there is little need for the -output-obj option, as
shown in the manual. Why not document the embedding by simply compiling
the C code tha provides the main function, which itself calls
caml_startup, and then linking it with the .cmx with ocamlopt? Why the
need for -output-obj, libasmrun.a, etc...?
--
Guillaume Yziquel
http://yziquel.homelinux.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-02-16 22:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-16 21:45 Embedding OCaml - manual not up to date Guillaume Yziquel
2010-02-16 22:35 ` Guillaume Yziquel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox