caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Dynlink, libcamlrun and ocamlrun: How to load libraries with external C functions
@ 2006-04-18 13:31 EL CHAAR Rabih   SGAM/AI/SAM
  0 siblings, 0 replies; 2+ messages in thread
From: EL CHAAR Rabih   SGAM/AI/SAM @ 2006-04-18 13:31 UTC (permalink / raw)
  To: caml-list

[-- 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 --]

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

* Dynlink, libcamlrun and ocamlrun: How to load libraries with external C functions
@ 2006-04-19  8:36 EL CHAAR Rabih   SGAM/AI/SAM
  0 siblings, 0 replies; 2+ messages in thread
From: EL CHAAR Rabih   SGAM/AI/SAM @ 2006-04-19  8:36 UTC (permalink / raw)
  To: caml-list

Sorry for sending back the same post, but last one was in MIME format.


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


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

end of thread, other threads:[~2006-04-19  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-18 13:31 Dynlink, libcamlrun and ocamlrun: How to load libraries with external C functions EL CHAAR Rabih   SGAM/AI/SAM
2006-04-19  8:36 EL CHAAR Rabih   SGAM/AI/SAM

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).