caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Ocamlbuild for project with C portion
@ 2009-09-21 16:05 Dario Teixeira
  2009-09-21 17:47 ` [Caml-list] " Eric Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Dario Teixeira @ 2009-09-21 16:05 UTC (permalink / raw)
  To: caml-list

Hi,

The Ocamlbuild manual begins by stating that the tool has builtin support
for projects with C stubs, but unfortunately is subsequently mute on the
subject.  So, I have a foobar.ml module that declares an external function
"stuff" which is defined in foobar_lowlevel.c.  What is the Ocamlbuild
tagging wizardry that allows this programme to compile?

Thanks in advance for your time!
Best regards,
Dario Teixeira

P.S. Does someone who groks it have plans to write a more complete manual
     for Ocamlbuild?  It's a tool whose great potential goes unfulfilled
     due to deficient documentation.






^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Ocamlbuild for project with C portion
  2009-09-21 16:05 Ocamlbuild for project with C portion Dario Teixeira
@ 2009-09-21 17:47 ` Eric Cooper
  2009-09-22 14:44   ` Dario Teixeira
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Cooper @ 2009-09-21 17:47 UTC (permalink / raw)
  To: caml-list

On Mon, Sep 21, 2009 at 09:05:42AM -0700, Dario Teixeira wrote:
> The Ocamlbuild manual begins by stating that the tool has builtin support
> for projects with C stubs, but unfortunately is subsequently mute on the
> subject.  So, I have a foobar.ml module that declares an external function
> "stuff" which is defined in foobar_lowlevel.c.  What is the Ocamlbuild
> tagging wizardry that allows this programme to compile?

There is an example in
  http://brion.inria.fr/gallium/index.php/Ocamlbuild_example_with_C_stubs 

The key is to create a file with the extension ".clib" that contains
the list of .o files that should be compiled from your C
stubs. Ocamlbuild will then build these into a libary (foo.clib will
result in foo.a).  You then add rules in myocamlbuild.ml that define
tags for depending on and linking with that library, and add these to
your _tags file.

-- 
Eric Cooper             e c c @ c m u . e d u


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Ocamlbuild for project with C portion
  2009-09-21 17:47 ` [Caml-list] " Eric Cooper
@ 2009-09-22 14:44   ` Dario Teixeira
  0 siblings, 0 replies; 3+ messages in thread
From: Dario Teixeira @ 2009-09-22 14:44 UTC (permalink / raw)
  To: caml-list, Eric Cooper

Hi,

> The key is to create a file with the extension ".clib" that contains
> the list of .o files that should be compiled from your C stubs. Ocamlbuild
> will then build these into a libary (foo.clib will result in foo.a).  You
> then add rules in myocamlbuild.ml that define tags for depending on and
> linking with that library, and add these to your _tags file.

Thanks for your reply.  In the end I managed to solve the problem, though
not using clib (which seems tangential to this problem).  All that was
required was the following myocamlbuild.ml:

open Ocamlbuild_plugin
open Command

let _ = dispatch begin function
        | After_rules ->
                flag ["ocaml"; "byte"; "link"] (S[A"-custom"]);
                dep ["ocaml"; "link"] ["foobar.o"]
        | _ -> ()
end


Though it still strikes me as odd that Ocamlbuild's manual won't cover
such basic examples...

Best regards,
Dario Teixeira






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-09-22 14:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-21 16:05 Ocamlbuild for project with C portion Dario Teixeira
2009-09-21 17:47 ` [Caml-list] " Eric Cooper
2009-09-22 14:44   ` Dario Teixeira

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).