From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 988AF820A1 for ; Tue, 10 Sep 2013 19:21:54 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of tom.j.ridge@googlemail.com) identity=pra; client-ip=209.85.192.170; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="tom.j.ridge@googlemail.com"; x-sender="tom.j.ridge@googlemail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of tom.j.ridge@googlemail.com designates 209.85.192.170 as permitted sender) identity=mailfrom; client-ip=209.85.192.170; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="tom.j.ridge@googlemail.com"; x-sender="tom.j.ridge@googlemail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-pd0-f170.google.com) identity=helo; client-ip=209.85.192.170; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="tom.j.ridge@googlemail.com"; x-sender="postmaster@mail-pd0-f170.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: As4BANBUL1LRVcCqm2dsb2JhbABbgz9Rr3CTbggWDgEBAQEBBgsLCRQogiUBAQVAAQEsDA8BFQ0NISISAQUBCggKBhMSDIdRAQMPDKIMiwyESgEFhCMKGScDCokZBo4qhVWXeYEvjlMYKYFhgmg7 X-IPAS-Result: As4BANBUL1LRVcCqm2dsb2JhbABbgz9Rr3CTbggWDgEBAQEBBgsLCRQogiUBAQVAAQEsDA8BFQ0NISISAQUBCggKBhMSDIdRAQMPDKIMiwyESgEFhCMKGScDCokZBo4qhVWXeYEvjlMYKYFhgmg7 X-IronPort-AV: E=Sophos;i="4.90,879,1371074400"; d="scan'208";a="32316507" Received: from mail-pd0-f170.google.com ([209.85.192.170]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 10 Sep 2013 19:21:53 +0200 Received: by mail-pd0-f170.google.com with SMTP id x10so7977709pdj.15 for ; Tue, 10 Sep 2013 10:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type:content-transfer-encoding; bh=R0KurkRom25Tb775OI8dqZGcOHnAcRF3uqVmzr9GQ/I=; b=lfWTmUeJWhHMKVuda91CeecEDK7FxpGNo+S/yYYT0ZWmzSDhGbelLrILlghIgCEuGG mR4/96xw/Tvud+vnnJNayrP6ziO1OghcXVbaZTax2tss+Fxx4dvdb46TYOU9TG3P8nIO Rp5fcsEoSdf5NFGNP8vK1yHZ+h+dwyfCNVgYm3kl9l1yO5qxD1vSVngU6IBy/R7ejsBB Rj2vPFN8mFisqXctHUlJYUU3YGD6eJpRawc/3BeD4bGHDewlVIm8XEmwS6g1KQ37Vtwo qpYapMjYXb1kinrKmGMQsUa09L0qje9tcTDtUQJ1MHwTjQcBAdBNcO7I47Q413PLK9tE Qi9A== X-Received: by 10.66.119.202 with SMTP id kw10mr16102406pab.118.1378833712355; Tue, 10 Sep 2013 10:21:52 -0700 (PDT) MIME-Version: 1.0 Sender: tom.j.ridge@googlemail.com Received: by 10.70.79.136 with HTTP; Tue, 10 Sep 2013 10:21:31 -0700 (PDT) In-Reply-To: References: <522F1A03.9020001@glondu.net> <522F2ADD.6010208@glondu.net> From: Tom Ridge Date: Tue, 10 Sep 2013 18:21:31 +0100 X-Google-Sender-Auth: 40F_LKn6ipaSa8scALgI1VgNyns Message-ID: To: caml-list Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Fwd: [Caml-list] Using OCaml from C Just to make a final report: Following Gerd and Stephane, I used ocamlfind -verbose to print the options ocamlfind was passing to cc. After tidying, my Makefile now looks like: -- SHELL=3Dbash OCAMLPATH=3D/home/tr61/.opam/4.00.1/lib all: ocamlfind ocamlc -package core,str -linkpkg -thread -output-obj -o modcaml.o pqueue.ml mod.ml ocamlc -c modwrap.c rm -f mod.a ar rcs mod.a modcaml.o modwrap.o cc -o prog main.c mod.a -L$(OCAMLPATH)/bin_prot -L$(OCAMLPATH)/variantslib -L$(OCAMLPATH)/num -L$(OCAMLPATH)/sexplib -L$(OCAMLPATH)/fieldslib -L$(OCAMLPATH)/oUnit -L$(OCAMLPATH)/pa_ounit -L$(OCAMLPATH)/res -L$(OCAMLPATH)/core_kernel -L$(OCAMLPATH)/core -L$(OCAMLPATH)/ocaml/threads -L$(OCAMLPATH)/ocaml -lcamlstr -lcore_stubs -lrt -lcore_kernel_stubs -lnums -lbin_prot_stubs -lbigarray -lthreads -lunix -lpthread -lunix -lcamlrun -I$(OCAMLPATH)/ocaml -lm -ldl -lcurses -lpthread -- which is better (e.g. no need for -pthread argument to cc, no need for -Xlinker --allow-multiple-definition), although a bit verbose (but the options were determined automatically, so this is a big time win). Thanks On 10 September 2013 15:21, St=E9phane Glondu wrote: > Le 10/09/2013 15:30, David Allsopp a =E9crit : >>> Your calls to cp, ar and your use of -custom look suspicious. But it is >>> difficult to be more helpful without a concrete testcase. >> >> They're exactly as in the manual and are correct for compiling with ocam= lc for static linking with C code. The cp and ar calls are necessary to set= -up the static library (which should use libcamlrun.a as a starting point) = - see #19.8 (the example in question), #19.7.4, #19.7.5 and #19.1.3 in the = manual. > > Well, that doesn't make them more right. > > With the example of the manual, the following works and is much saner: > > ocamlc -output-obj -o modcaml.o mod.ml > ocamlc -c modwrap.c > ar rcs mod.a modcaml.o modwrap.o > cc -o prog main.c mod.a -L`ocamlc -where` -lcamlrun -lm -ldl -lcurses > > Copying libcamlrun.a around and fiddling with it also works and avoids > -L`ocamlc -where` -lcamlrun but it is just insane, as insane as > embedding the C standard library and runtime into third-party static > libraries. > > > Cheers, > > -- > St=E9phane > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs