caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Dynamic libs w/ Ocaml + C code under Mac OS X
@ 2008-02-04 22:39 Joel Stanley
  2008-02-05  4:52 ` [Caml-list] " Alain Frisch
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Stanley @ 2008-02-04 22:39 UTC (permalink / raw)
  To: caml-list

Hi folks,

mfp from #ocaml suggested I send this off to the mailing list to see  
if anyone knows the answer.

The short question is: can I currently generate a shared library  
containing natively-compiled ocaml code together with arbitrary C code  
under Mac OS X?  Alain Frisch's natdynlink info page at http://alain.frisch.fr/natdynlink.html 
  seems to indicate that I can, but I'm not currently having much luck.

To wit, should I be doing something other than:

$ gcc -c wrapper.c
$ ocamlopt -dlcode -c simple.ml
...
$ ocamlopt -shared -o test simple.cmx wrapper.o

or perhaps just ocamlopt -shared -o test simple.ml wrapper.c?

The immediate problem is that this seems to be passing the wrong  
arguments to ld:

+ ld -bundle -flat_namespace -undefined suppress -read_only_relocs  
suppress -o 'test'  -I'/Users/jstanley/hbin/lib/ocaml' '-L/Users/ 
jstanley/hbin/lib/ocaml' 'test.startup.o' 'simple.o' 'wrapper.o'

(I'd expect to see gcc -dynamiclib (instead of bundle) here if Mac OS  
X is supported, and without the -I switch).

However, even attempting to use what I'd consider to be the "correct"  
linker invocation, I'm getting errors of the form:

ld: atom sorting error for _caml_shared_startup__code_begin and  
_caml_shared_startup__code_end in test.startup.o
ld: atom sorting error for _caml_shared_startup__code_begin and  
_caml_shared_startup__code_end in test.startup.o
ld: atom sorting error for _caml_shared_startup__code_begin and  
_caml_shared_startup__code_end in test.startup.o
ld: atom sorting error for _caml_shared_startup__code_begin and  
_caml_shared_startup__code_end in test.startup.o
ld: warning codegen in _camlSimple__f_58 (offset 0x00000008) prevents  
image from loading in dyld shared cache
ld: warning codegen in _camlSimple__entry (offset 0x00000004) prevents  
image from loading in dyld shared cache
ld: warning codegen in _camlSimple__entry (offset 0x00000009) prevents  
image from loading in dyld shared cache
ld: warning codegen in _camlSimple__entry (offset 0x0000000F) prevents  
image from loading in dyld shared cache
ld: warning codegen in _camlSimple__entry (offset 0x00000014) prevents  
image from loading in dyld shared cache
ld: warning codegen in _camlSimple__entry (offset 0x0000001E) prevents  
image from loading in dyld shared cache
ld: absolute addressing (perhaps -mdynamic-no-pic) used in  
_camlSimple__f_58 from simple.o not allowed in slidable image
collect2: ld returned 1 exit status

which lead me to believe that simple.o is not correctly being  
generated with position independence.

Thanks for any help you may be able to provide.

--
Joel Stanley






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

end of thread, other threads:[~2008-02-06  0:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-04 22:39 Dynamic libs w/ Ocaml + C code under Mac OS X Joel Stanley
2008-02-05  4:52 ` [Caml-list] " Alain Frisch
2008-02-05 16:39   ` Joel Stanley
2008-02-05 21:00     ` Alain Frisch
2008-02-05 21:19       ` Joel Stanley
2008-02-05 21:49         ` Alain Frisch
2008-02-06  0:02           ` Joel Stanley

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