From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id C5AE9BC6C for ; Mon, 4 Feb 2008 23:39:46 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAIcjp0dFHnvD/2dsb2JhbACseg X-IronPort-AV: E=Sophos;i="4.25,304,1199660400"; d="scan'208";a="6875208" Received: from galois.com (HELO mail.galois.com) ([69.30.123.195]) by mail2-smtp-roc.national.inria.fr with ESMTP; 04 Feb 2008 23:39:45 +0100 Received: from dyn-50-62.galois.com (dyn-50-62.galois.com [192.168.50.62]) (authenticated bits=0) by mail.galois.com (8.13.8/8.13.8) with ESMTP id m14MdMK3014242 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Mon, 4 Feb 2008 14:39:36 -0800 Message-Id: <11970BA6-EC2F-47FD-A194-BFD204057F06@galois.com> From: Joel Stanley To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v915) Subject: Dynamic libs w/ Ocaml + C code under Mac OS X Date: Mon, 4 Feb 2008 14:39:21 -0800 X-Mailer: Apple Mail (2.915) X-Virus-Scanned: ClamAV 0.92/5686/Mon Feb 4 13:13:58 2008 on liouville.galois.com X-Virus-Status: Clean X-Spam: no; 0.00; libs:01 ocaml:01 ocaml:01 frisch:01 gcc:01 ocamlopt:01 ocamlopt:01 -shared:01 cmx:01 -shared:01 'test':01 lib:01 ocaml':01 '-l:01 lib:01 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