Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Friedman Roy <roy@cs.technion.ac.il>, caml-list@inria.fr
Subject: Re: Linking caml generated object in NT
Date: Fri, 23 Oct 1998 11:30:49 +0200	[thread overview]
Message-ID: <19981023113049.35013@pauillac.inria.fr> (raw)
In-Reply-To: <Pine.GSO.3.95-heb-2.07.981020152420.5796C-100000@csa>; from Friedman Roy on Tue, Oct 20, 1998 at 03:29:08PM +0200

> I am trying to link object files generated by ocamlopt with object files
> generated by the C compiler (cl for instance) and got a lot of unknown
> symbols errors. I tried adding some or all of the libraries in the lib
> directory, and still a few symbols remained unknown. Is there a list of
> libraries one has to link with to make this work.

The main difficulty is that some glue code is generated at link-time
when you lin with ocamlopt, so in general you can't just link together
the .obj files produced by the ocamlopt compiler using another linker.

Your best bet is to use the "-output_obj" option to build a
self-contained .lib file with all your compiled Caml code + the glue
code generated at link-time + the OCaml runtime library:

        ocamlopt -output_obj -o mycamlcode.lib <the .cmx and .cmxa files
                                                 for your program>

Then, you need to provide a main() function in C to start the Caml
code.  The following should do:

int main(int argc, char ** argv) {
        caml_startup(argv);
        return 0;
}

Finally, use the NuMega linker to link together mycamlcode.lib,
the C libraries used by your Caml code, and the main() function above.

See the "Embedding the Caml code in the C code" and "Main program in C"
sections of the chapter "Interfacing C with Objective Caml" of the manual
for more details.

I haven't tried -output_obj under Windows in a long time, so the above
might not be 100% accurate, but I hope it will help.

- Xavier Leroy




      reply	other threads:[~1998-10-24 14:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-20 13:29 Friedman Roy
1998-10-23  9:30 ` Xavier Leroy [this message]

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=19981023113049.35013@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=roy@cs.technion.ac.il \
    /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