caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* MacOS port and file formats
@ 2004-12-31  2:02 Mary Fernandez
  2004-12-31  9:23 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 6+ messages in thread
From: Mary Fernandez @ 2004-12-31  2:02 UTC (permalink / raw)
  To: caml-list

Greetings,

I have a question regarding the ./configure options for MacOS/Darwin.

./configure selects the -bundle option for MKSHAREDLIB, which
has the effect of creating MacOS bundle type files for the dynamically
linked libraries in lib/ocaml/stublibs.  I have had trouble linking
these bundle files with the standard dynamically linked libraries
created with the -dynamiclib option.    As an experiment, I replaced
-bundle by -dynamiclib and attempted to rebuild the O'Caml compiler,
but got an error deep in compilation of the compiler.  Ultimately,
I just made the otherlibs/* libraries by hand with -dynamiclib and was
able
to link my application.

I will admit that I am overwhelmed by the Darwin documentation
that explains how to port a Linux application to MacOS. 
Can someone explain why the -bundle option is necessary to the compiler
compilation?
Is it because the O'Caml compiler a full-fledged Mac application?

Thanks, Mary
-- 
Mary Fernandez <mff@research.att.com>
AT&T Labs - Research


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

* Re: [Caml-list] MacOS port and file formats
  2004-12-31  2:02 MacOS port and file formats Mary Fernandez
@ 2004-12-31  9:23 ` Jacques Garrigue
  2004-12-31 15:08   ` Mary Fernandez
  0 siblings, 1 reply; 6+ messages in thread
From: Jacques Garrigue @ 2004-12-31  9:23 UTC (permalink / raw)
  To: mff; +Cc: caml-list

From: Mary Fernandez <mff@research.att.com>

> I have a question regarding the ./configure options for MacOS/Darwin.
> 
> ./configure selects the -bundle option for MKSHAREDLIB, which
> has the effect of creating MacOS bundle type files for the dynamically
> linked libraries in lib/ocaml/stublibs.  I have had trouble linking
> these bundle files with the standard dynamically linked libraries
> created with the -dynamiclib option.    As an experiment, I replaced
> -bundle by -dynamiclib and attempted to rebuild the O'Caml compiler,
> but got an error deep in compilation of the compiler.  Ultimately,
> I just made the otherlibs/* libraries by hand with -dynamiclib and was
> able
> to link my application.
> 
> I will admit that I am overwhelmed by the Darwin documentation
> that explains how to port a Linux application to MacOS. 
> Can someone explain why the -bundle option is necessary to the compiler
> compilation?
> Is it because the O'Caml compiler a full-fledged Mac application?

Could you explain exactly what you are trying to do?
The dlls in stublibs are only intended to be dynamically loaded by an
ocaml application. The reason bundles are used rather than dynamic
libraries is that the API for bundles is simpler, and that their
explicit intent (plugins) seems close enough to the use of dlls in
ocaml.
Note that a bundle can depend on dynamic libraries, so this should not
induce other limitations.

Jacques Garrigue


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

* Re: [Caml-list] MacOS port and file formats
  2004-12-31  9:23 ` [Caml-list] " Jacques Garrigue
@ 2004-12-31 15:08   ` Mary Fernandez
  2005-01-02  1:35     ` Jacques Garrigue
  0 siblings, 1 reply; 6+ messages in thread
From: Mary Fernandez @ 2004-12-31 15:08 UTC (permalink / raw)
  To: Jacques Garrigue; +Cc: caml-list

Hi Jacques,

Thanks for your message.  Here is what I am trying to do.

My O'Caml application is an XQuery engine.  It has three
APIs: one for O'Caml, one for C, and one for Java applications.

We create a native-code, dynamically linked
C library that includes our O'Caml library, the O'Caml runtime,
and several other C libraries that our application depends upon
the unix, nums, str libraries plus an external PCRE library.
We actually do this by hand with ocamlopt (not ocamlmklib)
because in the past, we found ocamlmklib did not work consistently
on all platforms.

What I have found is that if the dll*.so libraries are Mac bundle
files, then I get a linking error of the form 
"...ld: /Users/mff/ocaml-3.08.2/lib/ocaml/stublibs/libstr.dylib is input
for the dynamic link editor, is not relocatable by the static link
editor again..."
(Note that the default name of dllstr.so is not recognized by the 
Darwin linker).  If I re-compile the otherlibs/ in stublibs/
to be dynamically linked libraries, then I have no problems.
Also, if I just use the archive files, that works too -- but
I typically use O'Caml with dynamic libs enabled which is how
I tripped over this problem.

We only create a dynamically linked library, because 
our Java library call the C library, and the Java JNI requires
dynamically linked C libraries.

So, in short, I have something that works, but still dont'
understand why bundles and dynamically linked libraries caused
me trouble.

Thanks,Mary

On Fri, 2004-12-31 at 04:23, Jacques Garrigue wrote:
> From: Mary Fernandez <mff@research.att.com>
> 
> > I have a question regarding the ./configure options for MacOS/Darwin.
> > 
> > ./configure selects the -bundle option for MKSHAREDLIB, which
> > has the effect of creating MacOS bundle type files for the dynamically
> > linked libraries in lib/ocaml/stublibs.  I have had trouble linking
> > these bundle files with the standard dynamically linked libraries
> > created with the -dynamiclib option.    As an experiment, I replaced
> > -bundle by -dynamiclib and attempted to rebuild the O'Caml compiler,
> > but got an error deep in compilation of the compiler.  Ultimately,
> > I just made the otherlibs/* libraries by hand with -dynamiclib and was
> > able
> > to link my application.
> > 
> > I will admit that I am overwhelmed by the Darwin documentation
> > that explains how to port a Linux application to MacOS. 
> > Can someone explain why the -bundle option is necessary to the compiler
> > compilation?
> > Is it because the O'Caml compiler a full-fledged Mac application?
> 
> Could you explain exactly what you are trying to do?
> The dlls in stublibs are only intended to be dynamically loaded by an
> ocaml application. The reason bundles are used rather than dynamic
> libraries is that the API for bundles is simpler, and that their
> explicit intent (plugins) seems close enough to the use of dlls in
> ocaml.
> Note that a bundle can depend on dynamic libraries, so this should not
> induce other limitations.
> 
> Jacques Garrigue
-- 
Mary Fernandez <mff@research.att.com>
AT&T Labs - Research


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

* Re: [Caml-list] MacOS port and file formats
  2004-12-31 15:08   ` Mary Fernandez
@ 2005-01-02  1:35     ` Jacques Garrigue
  2005-01-02 12:23       ` Jacques GARRIGUE
  0 siblings, 1 reply; 6+ messages in thread
From: Jacques Garrigue @ 2005-01-02  1:35 UTC (permalink / raw)
  To: mff; +Cc: caml-list

From: Mary Fernandez <mff@research.att.com>

> Thanks for your message.  Here is what I am trying to do.
> 
> My O'Caml application is an XQuery engine.  It has three
> APIs: one for O'Caml, one for C, and one for Java applications.
> 
> We create a native-code, dynamically linked
> C library that includes our O'Caml library, the O'Caml runtime,
> and several other C libraries that our application depends upon
> the unix, nums, str libraries plus an external PCRE library.
> We actually do this by hand with ocamlopt (not ocamlmklib)
> because in the past, we found ocamlmklib did not work consistently
> on all platforms.

To be more precise, ocamlmklib produces two kinds of output: a DLL for
dynamic loading in bytecode programs, and a static library for custom
and native programs.
What you seem to want is a dynamic library to link with native
programs, which is out of the specification.

On most architectures, the DLL can be used as a dynamic library, but
this is not true on darwin, and only partly true on windows (you also
need a binding library, which is not kept.)

If your concern is darwin, then there is a simple answer: you can just
get the installed static library, and turn it into a dynamic library,
as all C code on darwin is position independent. Just look for the
correct linker incantation in the darwin manual.
It's better not to try to meddle with the core ocaml compilation,
which has different goals in mind.

Hope this helps,

Jacques Garrigue


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

* Re: [Caml-list] MacOS port and file formats
  2005-01-02  1:35     ` Jacques Garrigue
@ 2005-01-02 12:23       ` Jacques GARRIGUE
  2005-01-04  3:29         ` Mary Fernandez
  0 siblings, 1 reply; 6+ messages in thread
From: Jacques GARRIGUE @ 2005-01-02 12:23 UTC (permalink / raw)
  To: garrigue; +Cc: mff, caml-list

> From: Mary Fernandez <mff@research.att.com>
> > We create a native-code, dynamically linked
> > C library that includes our O'Caml library, the O'Caml runtime,
> > and several other C libraries that our application depends upon
> > the unix, nums, str libraries plus an external PCRE library.
> 
> If your concern is darwin, then there is a simple answer: you can just
> get the installed static library, and turn it into a dynamic library,
> as all C code on darwin is position independent. Just look for the
> correct linker incantation in the darwin manual.

In case you could not find it, here is the incantation:

  ld -dylib -all_load -flat_namespace -undefined suppress 
    /usr/local/lib/ocaml/libunix.a -ldylib1.o -o libunix.dylib

You can also link all these libraries directly in your dynamic linked
C library, without creating individual dlls (but this works only for
platforms such as darwin, where all code is position independent).

Jacques Garrigue


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

* Re: [Caml-list] MacOS port and file formats
  2005-01-02 12:23       ` Jacques GARRIGUE
@ 2005-01-04  3:29         ` Mary Fernandez
  0 siblings, 0 replies; 6+ messages in thread
From: Mary Fernandez @ 2005-01-04  3:29 UTC (permalink / raw)
  To: Jacques GARRIGUE; +Cc: garrigue, caml-list

Jacques,
Thanks for all the detailed info and help.  We decided to just use
the static libraries as it simplifies our other ports, 
but this is all very helpful info.  We have our MacOS
library working with C & Java.
Thanks, Mary
On Sun, 2005-01-02 at 07:23, Jacques GARRIGUE wrote:
> > From: Mary Fernandez <mff@research.att.com>
> > > We create a native-code, dynamically linked
> > > C library that includes our O'Caml library, the O'Caml runtime,
> > > and several other C libraries that our application depends upon
> > > the unix, nums, str libraries plus an external PCRE library.
> > 
> > If your concern is darwin, then there is a simple answer: you can just
> > get the installed static library, and turn it into a dynamic library,
> > as all C code on darwin is position independent. Just look for the
> > correct linker incantation in the darwin manual.
> 
> In case you could not find it, here is the incantation:
> 
>   ld -dylib -all_load -flat_namespace -undefined suppress 
>     /usr/local/lib/ocaml/libunix.a -ldylib1.o -o libunix.dylib
> 
> You can also link all these libraries directly in your dynamic linked
> C library, without creating individual dlls (but this works only for
> platforms such as darwin, where all code is position independent).
> 
> Jacques Garrigue
-- 
Mary Fernandez <mff@research.att.com>
AT&T Labs - Research


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

end of thread, other threads:[~2005-01-04  3:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-31  2:02 MacOS port and file formats Mary Fernandez
2004-12-31  9:23 ` [Caml-list] " Jacques Garrigue
2004-12-31 15:08   ` Mary Fernandez
2005-01-02  1:35     ` Jacques Garrigue
2005-01-02 12:23       ` Jacques GARRIGUE
2005-01-04  3:29         ` Mary Fernandez

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