From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 5DD4BBC57 for ; Tue, 2 Mar 2010 08:42:33 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsUAAFNQjEsmachzmWdsb2JhbACbBhUBAQEBAQYNCgcTIr1ZhHsEjjQ X-IronPort-AV: E=Sophos;i="4.49,564,1262559600"; d="scan'208";a="58013195" Received: from mx2.janestreet.com ([38.105.200.115]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 02 Mar 2010 08:42:33 +0100 Received: from nyc-qsv-mail1.delacy.com ([172.25.22.57]) by mx2.janestreet.com with esmtp (Exim 4.71) (envelope-from ) id 1NmMkQ-0005aA-Pn; Tue, 02 Mar 2010 02:42:30 -0500 Received: from nyc-qsv-004.delacy.com ([172.25.22.194] helo=qsmtp.delacy.com) by nyc-qsv-mail1.delacy.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.71) (envelope-from ) id 1NmMkR-0002FM-34; Tue, 02 Mar 2010 02:42:31 -0500 Received: from lon-qws-r01.delacy.com ([172.30.3.51] helo=lon-qws-r01) by qsmtp.delacy.com with smtp (Exim 4.71) (envelope-from ) id 1NmMkP-0007iD-Ue; Tue, 02 Mar 2010 02:42:31 -0500 Received: by lon-qws-r01 (sSMTP sendmail emulation); Tue, 2 Mar 2010 07:42:29 +0000 From: "Mark Shinwell" Date: Tue, 2 Mar 2010 07:42:29 +0000 To: Jianzhou Zhao Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Debugging C and OCaml Message-ID: <20100302074229.GH26002@janestreet.com> References: <9dfe358d1003010710r69799c1duae37c42a3725b899@mail.gmail.com> <20100301151940.GD26002@janestreet.com> <9dfe358d1003011648g58c07831p9b27bc76276a9461@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9dfe358d1003011648g58c07831p9b27bc76276a9461@mail.gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-Spam: no; 0.00; shinwell:01 ocaml:01 shinwell:01 ocaml:01 'ocamlc:01 -custom:01 -output-obj:01 compilation:01 usr:01 lib:01 gcc:01 ocaml-:01 lib:01 libasmrun:01 recompile:01 On Mon, Mar 01, 2010 at 07:48:56PM -0500, Jianzhou Zhao wrote: > On Mon, Mar 1, 2010 at 10:19 AM, Mark Shinwell wrote: > I compiled OCaml code into *.o by 'ocamlc -custom -output-obj...', > and then linked it with *.o from C and C++ code. > I think this isnt a native compilation. Agreed. > My main C++ program is eventually compiled into a shared library. > If I do 'ocamlopt', ld reports: > /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: > /mnt/eclipse/acg/users/jianzhou/tools/ocaml-3.11.2//lib/ocaml/libasmrun.a(amd64.o): > relocation R_X86_64_PC32 against symbol `caml_last_return_address' can > not be used when making a shared object; recompile with -fPIC You need to build the runtime as position-independent code. Unfortunately this is non-trivial. I suggest you try looking at this thread which may help you: http://caml.inria.fr/pub/ml-archives/caml-list/2010/01/9894615c02692ca5b86e2a891d8cf324.en.html Mark