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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 45593BBAF for ; Sun, 15 Nov 2009 15:55:58 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjgEAOCk/0qAAtnEmWdsb2JhbACBTJMBh04BAQEBAQgLCgcTp3uEZYhPhDwE X-IronPort-AV: E=Sophos;i="4.44,746,1249250400"; d="scan'208";a="36768177" Received: from smtp01.srv.cs.cmu.edu ([128.2.217.196]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 15 Nov 2009 15:55:57 +0100 Received: from stratocaster.home (pool-96-236-220-64.pitbpa.fios.verizon.net [96.236.220.64]) (authenticated bits=0) by smtp01.srv.cs.cmu.edu (8.13.6/8.13.6) with ESMTP id nAFEtsnQ025420 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Sun, 15 Nov 2009 09:55:55 -0500 (EST) Received: from ecc by stratocaster.home with local (Exim 4.69) (envelope-from ) id 1N9gW8-0003qn-V5 for caml-list@yquem.inria.fr; Sun, 15 Nov 2009 09:55:52 -0500 Date: Sun, 15 Nov 2009 09:55:52 -0500 From: Eric Cooper To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] calling OCaml from C on non-Mac platforms? Message-ID: <20091115145552.GA14456@localhost> Mail-Followup-To: caml-list@yquem.inria.fr References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Scanned-By: mimedefang-cmuscs on 128.2.217.196 X-Spam: no; 0.00; ocaml:01 ocaml:01 ocamlopt:01 -output-obj:01 cmx:01 ocamlopt:01 -output-obj:01 gcc:01 usr:01 lib:01 -lm:01 -ldl:01 2009:98 wrote:01 caml-list:01 On Sun, Nov 15, 2009 at 08:27:49AM -0500, John Nowak wrote: > I'm trying to call OCaml from C. > [...] > ocamlopt -output-obj hello.cmx -o hello.o This is the main problem. You're clobbering the hello.o that OCaml produced when compiling hello.ml into native code. > Does anyone have a correct set of instructions for doing this on > non-Mac platforms? Thanks. This worked fine for me: ocamlopt -output-obj -o temp.o hello.ml gcc -o hello main.c temp.o -L/usr/lib/ocaml -lasmrun -lm -ldl