caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Emir Pasalic <pasalic@cs.rice.edu>
To: caml-list@yquem.inria.fr
Subject: Dynamic linking
Date: Tue, 5 Apr 2005 16:12:51 -0500	[thread overview]
Message-ID: <263b229a999e9788124e5fc0129a814f@cs.rice.edu> (raw)

We are writing a program that generates a C file, compiles it to a 
dynamic library, and uses dlopen (and such) to load it, execute it and 
bring its value into ocaml (bytecode) runtime. To do this, we need to 
use some of the functionality of the ocaml runtime (e.g., caml_alloc, 
caml_update) so we can marshall values from the C world into the world 
of ocaml. Our solution works on linux and macos platforms, but we have 
a problem trying to make it run on windows with Cygwin.

So, we're trying to create a shared library on Cygwin that contains 
symbols such as "caml_alloc" and "caml_update".
  We do not know of a way to easily incorporate these symbols in the 
linking process, and so they
remain undefined when we try to create a library, and undefined symbols 
are not allowed in Cygwin shared libraries.

Therefore we tried to resort to another method, where the calls to  
caml_alloc and caml_update are replaced by
calls to dlopen and dlsym functions, i.e., we were trying to do this:

        h = dlopen ("<the library name>", RLTD_NOW);
        /* process error */
        s = dlsym (h, "caml_alloc");
        /* process error */
        my_alloc = /* proper casting */ s;
        result = my_alloc ( /* arguments */ );

Assuming that this is possible, what is the name that should be given 
to the library?
Else, is it possible to build a shared library on Cygwin that contains 
references to these symbols?

Note that all this works perfectly fine on MacOS and linux which allow 
unresolved symbols in dynamic libraries, but Cygwin simply dies. Any 
Windows/Cygwin experts out there who can help us?


             reply	other threads:[~2005-04-05 21:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-05 21:12 Emir Pasalic [this message]
2005-04-05 22:02 ` [Caml-list] " Igor Pechtchanski
2007-06-15 16:03 Alain Frisch

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=263b229a999e9788124e5fc0129a814f@cs.rice.edu \
    --to=pasalic@cs.rice.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).