caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Robert Roessler <roessler@rftp.com>
To: Aaron Bohannon <bohannon@cis.upenn.edu>
Cc: OCaml List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] linking errors involving cpp files
Date: Mon, 14 Dec 2009 22:59:57 -0800	[thread overview]
Message-ID: <BLU0-SMTP2107EC0D977E613FCE7F09C7880@phx.gbl> (raw)
In-Reply-To: <c413fcb70912142109s39a01f6epd4c07ed31e0a0635@mail.gmail.com>

Aaron Bohannon wrote:
> How do I link C++ code with OCaml?  Let's say I have a main program in
> C/C++ and a function I want to call in OCaml:
>
> ---- main.c / main.cpp ---
> #include<caml/mlvalues.h>
> #include<caml/memory.h>
> #include<caml/callback.h>
> int main (int argc, char ** argv) {
>    char * caml_argv[argc + 1];
>    int i;
>    for (i = 0; i<  argc + 1; i++) caml_argv[i] = argv[i];
>    caml_argv[argc] = NULL;
>    caml_main (caml_argv);
>    return 0;
> }
> --------
>...
> ---then I get this:
>
> Undefined symbols:

You might try (when mixing C++ and OCaml) wrapping the whole thing in an 
'extern "C" {...}' block (*including* the #includes and the entire main 
function).

Robert Roessler


  reply	other threads:[~2009-12-15  7:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-15  5:09 Aaron Bohannon
2009-12-15  6:59 ` Robert Roessler [this message]
2009-12-15 13:50   ` [Caml-list] " Aaron Bohannon
2009-12-15 13:59     ` Mark Shinwell
2009-12-15 20:47       ` Aaron Bohannon
2009-12-15 14:50     ` Jan Kybic
2009-12-15 15:04       ` Basile STARYNKEVITCH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BLU0-SMTP2107EC0D977E613FCE7F09C7880@phx.gbl \
    --to=roessler@rftp.com \
    --cc=bohannon@cis.upenn.edu \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).