caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "EL CHAAR Rabih   SGAM/AI/SAM" <RABIH.ELCHAAR@sgam.com>
To: <caml-list@inria.fr>
Subject: Dynlink, libcamlrun and ocamlrun: How to load libraries with external C functions
Date: Tue, 18 Apr 2006 15:31:40 +0200	[thread overview]
Message-ID: <7F070E410B10EE419826BF5206322CC2095265@frdef-exmb01.europe.am.socgen> (raw)

[-- Attachment #1: Type: text/plain, Size: 3609 bytes --]

Hello everyone,

 

We have the following constraint:

We are planning to use an executable (let's name it A) from a
third-party, built upon ocaml.

It enables us to load our inhouse caml libraries via the Dynlink module.

The executable A is statically linked against libcamlrun.lib

 

Several of our libraries use external C functions, and we have them
built in two flavours : .cma for statically linked executables, and
_d.cma for loading via the toplevel (linked therefore with
ocamlrun.lib).

 

Our goal is to be able to load these libraries dynamically against A
(since we can't recompile A).

 

After making sure that the Dynlink module enables unsafe features, we
tried to load these libraries (_d.cma) and we were facing some access
violation exceptions.

After a thorough investigation, this seems to come from the fact that
our libraries were creating values with respect to ocamlrun runtime, and
the executable is expecting values with respect to libcamlrun runtime.
I'm not an expert on this issue (links are really appreciated), but
these two runtimes don't seem to share the same memory representation of
values (the exceptions were arising when calling from c functions like
caml_copy_double, ...).

 

This seems to point that it is not possible to use jointly libraries
with ocamlrun and libcamlrun runtimes, which is quite understandable.

 

We still need these libraries to be loaded dynamically, and they have
some external C functions. I have the impression that the only way to do
these is through linking with ocamlrun.lib and defining the CAML_DLL
symbol for the exported function using the Camlprim keyword.

 

I tried to switch the link library from ocamlrun to libcamlrun, but I
was having some undefined symbols 

 

b.obj : error LNK2019: unresolved external symbol __imp__caml_failwith
referenced in function ...

b.obj : error LNK2019: unresolved external symbol
__imp__caml_local_roots referenced in function ...

b.obj : error LNK2019: unresolved external symbol
__imp__caml_alloc_custom referenced in function ...

b.obj : error LNK2019: unresolved external symbol
__imp__caml_copy_double referenced in function ...

 

1)       Is there a way to create such libraries with the libcamlrun
runtime ?

2)       What is the correct approach to load libraries through Dynlink
with external functions ?

 

 

Thanks in advance for your help and advices.

If the post seems vague, please point it out and i'll give more
explanations or details.

Sincerely yours,

 

Rabih Chaar

Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses destinataires. 
Toute utilisation ou diffusion non autorisee est interdite. 
Tout message electronique est susceptible d'alteration. 
Societe Generale Asset Management et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie. 
  
Decouvrez l'offre et les services de Societe Generale Asset Management sur le site www.sgam.fr 
  
                                ******** 
  
This message and any attachments (the "message") are confidential and intended solely for the addressees. 
Any unauthorised use or dissemination is prohibited. 
E-mails are susceptible to alteration. 
Neither Societe Generale Asset Management nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified. 
 
Find out more about Societe Generale Asset Management's proposal on www.sgam.com

[-- Attachment #2: Type: text/html, Size: 10562 bytes --]

             reply	other threads:[~2006-04-18 13:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-18 13:31 EL CHAAR Rabih   SGAM/AI/SAM [this message]
2006-04-19  8:36 EL CHAAR Rabih   SGAM/AI/SAM

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=7F070E410B10EE419826BF5206322CC2095265@frdef-exmb01.europe.am.socgen \
    --to=rabih.elchaar@sgam.com \
    --cc=caml-list@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).