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 B41AE801CD for ; Sun, 27 Aug 2017 21:56:07 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=kennethadammiller@gmail.com; spf=Pass smtp.mailfrom=kennethadammiller@gmail.com; spf=None smtp.helo=postmaster@mail-lf0-f48.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of kennethadammiller@gmail.com) identity=pra; client-ip=209.85.215.48; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="kennethadammiller@gmail.com"; x-sender="kennethadammiller@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of kennethadammiller@gmail.com designates 209.85.215.48 as permitted sender) identity=mailfrom; client-ip=209.85.215.48; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="kennethadammiller@gmail.com"; x-sender="kennethadammiller@gmail.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-lf0-f48.google.com) identity=helo; client-ip=209.85.215.48; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="kennethadammiller@gmail.com"; x-sender="postmaster@mail-lf0-f48.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3Ar1up3xEXKw3pehBfkqWkY51GYnF86YWxBRYc798d?= =?us-ascii?q?s5kLTJ76r8iwAkXT6L1XgUPTWs2DsrQf1LqQ7viocFdDyKjCmUhKSIZLWR4BhJ?= =?us-ascii?q?detC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TXhpQIVTx72MA49?= =?us-ascii?q?O//4AJWa28++0uT3/5zIfy1JgiC8aPV8NkPlgx/Ws5w1jI1kJ7oxgjLFq34AXu?= =?us-ascii?q?VSwW5ybQaQkhD669uw9ZJq9iFRv/Ys7eZPVKz7e+IzSrkOX2duCHw8+MC+7UqL?= =?us-ascii?q?dgCI/HZJCmg=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0A8AgDTIqNZfzDXVdFdHAEBBAEBCgEBF?= =?us-ascii?q?wEBBAEBCgEBgkSBT4EVB4NwgTaYfIFxd49xh1AwhRcCg1wHQxQBAQEBAQEBAQE?= =?us-ascii?q?BARIBAQkLCwgmMYIzIoJDAQEBAQIBIx0BGx4DAQsGAwILDSoCAiEBAREBBQEcB?= =?us-ascii?q?hOKGAEDDQgQlEqRG0CMC4IFBQEcgwkFg1QKGScNV4NEAQEBBwEBAQEcAgYSgxi?= =?us-ascii?q?CAoMxgnM1gleCS4JmgmEFiVUlDocZgWeNIDyHVod6hHaCElqBFId1hnOMSRCIG?= =?us-ascii?q?xUfgRU2gS4yISR4gjWCECqCLiQ2AYsEAQEB?= X-IPAS-Result: =?us-ascii?q?A0A8AgDTIqNZfzDXVdFdHAEBBAEBCgEBFwEBBAEBCgEBgkS?= =?us-ascii?q?BT4EVB4NwgTaYfIFxd49xh1AwhRcCg1wHQxQBAQEBAQEBAQEBARIBAQkLCwgmM?= =?us-ascii?q?YIzIoJDAQEBAQIBIx0BGx4DAQsGAwILDSoCAiEBAREBBQEcBhOKGAEDDQgQlEq?= =?us-ascii?q?RG0CMC4IFBQEcgwkFg1QKGScNV4NEAQEBBwEBAQEcAgYSgxiCAoMxgnM1gleCS?= =?us-ascii?q?4JmgmEFiVUlDocZgWeNIDyHVod6hHaCElqBFId1hnOMSRCIGxUfgRU2gS4yISR?= =?us-ascii?q?4gjWCECqCLiQ2AYsEAQEB?= X-IronPort-AV: E=Sophos;i="5.41,437,1498514400"; d="scan'208,217";a="288495378" Received: from mail-lf0-f48.google.com ([209.85.215.48]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 27 Aug 2017 21:56:06 +0200 Received: by mail-lf0-f48.google.com with SMTP id d17so15180506lfe.1 for ; Sun, 27 Aug 2017 12:56:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=kzpBf+J0YUpAwtvDSq3bz3MTqloX2jWHAtI2YMcx4v0=; b=XEIZnf1M9tHTZLPe4pKVol1N1x2g6vExj7zYoqh0mP5BglwgknMu7e2hrbUYRVMQhA V6d4mfDkWcV8vUwk9Uz0xOW/KLBWYhznSmewAPBFiv4GrH+Tcb8ca8/4RHH86fzI4FWz ds8SUuIhV06Yu8ahuVzy8OGgEC9WtrXGIP19cFCFyUQ+RpIUeLujEd/VCh7CqC4IaHEm K+vdmAd2PzAbRynns7wuS/AOJpzjCioZ3NcyRvBg0BIzNlk52GiYi/CV6F40MkSiYHbG HHCKAyt3SRlR05Snz6AQubutUz1T724aRe9t2HzIbSSxyi7yMl3aazal/pQHyaTPsN/X GNyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=kzpBf+J0YUpAwtvDSq3bz3MTqloX2jWHAtI2YMcx4v0=; b=t0z2CTlixpAM4lMPbY0pa9NRUCsHUbn34X1/MOdH1ryDbDL8J7fsSEgSH7H2p25UO+ 25pSN7lYq38glAyh+FW+4WdfNmg+w4iQY9Ve5T3My7QdpCGemARy0vMycN52JVOpR7e3 1QRUnNvdVwj+8v88sJthNDK5YFUhBZKJWe/hIfsNzWt9alpEOEc6RDwP1oc1ula2/IQs TMtu/spvKqjR/DKzH6sNMUNtN4D1cd16F3jKf3AuXJU38aWoYgLGoMIttVGlX2w3EVUl bO31k9KpNZntZ16MIAzo5ocsaz3EilZQz4tiiLKXvrV5c6l0W2BWkkdq8eAIJbY+3J1i 3lQg== X-Gm-Message-State: AHYfb5hwXfXtccrhHwWpEVrIHoWj5VkMq9FF9iGMIh/uWAFdgVm9ltbG tY7ph3EOdUlJE86PTGHwaxqihlecVMcK X-Received: by 10.46.1.3 with SMTP id 3mr1658612ljb.85.1503863765272; Sun, 27 Aug 2017 12:56:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.46.81.18 with HTTP; Sun, 27 Aug 2017 12:56:04 -0700 (PDT) In-Reply-To: References: From: Kenneth Adam Miller Date: Sun, 27 Aug 2017 15:56:04 -0400 Message-ID: To: caml users Content-Type: multipart/alternative; boundary="001a1142be568512330557c19118" Subject: Re: [Caml-list] oasis and C wrapper --001a1142be568512330557c19118 Content-Type: text/plain; charset="UTF-8" Ok, so I got the with-c example to build by running -configure before I built with ocaml setup.ml -build, and that worked. But then there's a part in there where ocamlbuild is passed a libwith-c_stubs.a target and it knows what to do with it. I've tried to copy that example line by line in my _oasis and command line steps, and I have know what calls ocamlbuild should be making to get the .cma and .cmxa targets. But I can't get my _oasis to work. On Sun, Aug 27, 2017 at 1:19 AM, Kenneth Adam Miller < kennethadammiller@gmail.com> wrote: > Actually, I think it's that ocamlbuild should be told to link > libdai_stubs.a, and not try and build it. But also, I wanted to reference > an existing work that links with C libraries, and I found ocamlbuild's > example, with-c. I tried to build it, and I found that it isn't built by > the harness default. Also, if you just try and build within just that raw > directory in isolation, that it fails with a similar error I had been > getting earlier. I looked around and found these: > > https://stackoverflow.com/questions/19644451/how-to- > make-ocamlbuild-compile-and-link-a-c-file-into-an-ocaml-project > https://l-lang.blogspot.com/2012/08/incorporating-c-code- > in-ocaml-project.html > https://ocaml.org/learn/tutorials/ocamlbuild/Using_an_ > external_library.html > > And I'm trying to follow, but they each give unique directions, each seem > to not work for me. > > On Sat, Aug 26, 2017 at 9:12 PM, Kenneth Adam Miller < > kennethadammiller@gmail.com> wrote: > >> Hello, >> >> >> I'm building a pair of companion oasis build spec and opam package setup >> for a C library. libdai I figured out how to get swig and oasis to build >> most things I need, but I'm having trouble getting oasis to not generate >> _stubs targets that aren't found. There is a static C/++ libdai.a file that >> is the product of the project I'm trying to wrap. I can't convince oasis to >> use that instead. Here's my _oasis target: >> >> >> Library "dai" >> Path: ./ >> Install: false >> Modules: Swig, Dai >> CompiledObject: best >> CSources: dai_wrap.cxx.c >> CCOpt: -g -xc++ "-I../../include" >> >> >> With a fresh clone of libdai, I get dai_wrap.cxx.c by doing the following >> in ./swig after building libdai: >> >> $(SWIG) -ocaml -c++ dai.i >> mv dai_wrap.cxx dai_wrap.cxx.c >> sed -i -e 's/caml_array_length/caml_array_len/g' dai_wrap.cxx.c >> >> I got my swig and dai ml files by doing the following: >> >> swig2.0 -ocaml -co dai.ml >> swig2.0 -ocaml -co swig.ml >> swig2.0 -ocaml -co swig.mli >> >> I build by doing the following: >> >> ocaml setup.ml -configure >> ocaml setup.ml -build >> >> >> I get the following error: >> >> >> Solver failed: >> Ocamlbuild knows of no rules that apply to a target named >> ./libdai_stubs.a. This can happen if you ask Ocamlbuild to build a target >> with the wrong extension (e.g. .opt instead of .native) or if the source >> files live in directories that have not been specified as include >> directories. >> Compilation unsuccessful after building 8 targets (8 cached) in 00:00:00. >> E: Failure("Command ''/usr/bin/ocamlbuild' ./libdai_stubs.a >> ./dlldai_stubs.so ./dai.cma ./dai.cmxa ./dai.a ./dai.cmxs -j 5 -tag debug' >> terminated with error code 6") >> >> I want to make sure that the actual target shared library that was >> produced by the libdai build file itself is linked against. But oasis is >> assuming I have a _stubs target. I read in the documentation here that: "The >> usual idiom is to append _stubs to the name." >> https://ocaml.org/learn/tutorials/setting_up_with_oasis. >> html#Interfacing-with-C-code >> >> And I think that that is the source of the error, but it isn't well >> explained. The ultimate things I originally wanted was to be able to use >> libdai with both the utop or the bytecode interpreter and with fully >> compiled targets. I was going to make libdai a library and then publicize >> it. >> >> If anybody needs to replicate my issue, I have a docker container with >> this already. >> > > --001a1142be568512330557c19118 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ok, so I got the with-c example to build by running -confi= gure before I built with ocaml setup.ml -bu= ild, and that worked. But then there's a part in there where ocamlbuild= is passed a libwith-c_stubs.a target and it knows what to do with it. I= 9;ve tried to copy that example line by line in my _oasis and command line = steps, and I have know what calls ocamlbuild should be making to get the .c= ma and .cmxa targets. But I can't get my _oasis to work.

On Sun, Aug 27, 2017 at 1:= 19 AM, Kenneth Adam Miller <kennethadammiller@gmail.com><= /span> wrote:
Actually, = I think it's that ocamlbuild should be told to link libdai_stubs.a, and= not try and build it. But also, I wanted to reference an existing work tha= t links with C libraries, and I found ocamlbuild's example, with-c. I t= ried to build it, and I found that it isn't built by the harness defaul= t. Also, if you just try and build within just that raw directory in isolat= ion, that it fails with a similar error I had been getting earlier. I looke= d around and found these:

https://ocaml.org/l= earn/tutorials/ocamlbuild/Using_an_external_library.html
<= /div>

And I'm trying to follow, but they each give u= nique directions, each seem to not work for me.

On Sat, Aug 26, 2017 at 9:12 PM, Kenneth Adam Miller <ken= nethadammiller@gmail.com> wrote:
Hello,


I'm bui= lding a pair of companion oasis build spec and opam package setup for a C l= ibrary. libdai I figured out how to get swig and oasis to build most things= I need, but I'm having trouble getting oasis to not generate _stubs ta= rgets that aren't found. There is a static C/++ libdai.a file that is t= he product of the project I'm trying to wrap. I can't convince oasi= s to use that instead. Here's my _oasis target:

=
Library "dai"
=C2=A0 Path: =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ./
=C2=A0 Install: =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0false
=C2=A0 Modules= : =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Swig, Dai
=C2= =A0 CompiledObject: =C2=A0 =C2=A0 =C2=A0 best
=C2=A0 CSources: = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dai_wrap.cxx.c
=C2=A0 C= COpt: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-g -xc++ "= ;-I../../include"


With a fresh clon= e of libdai, I get dai_wrap.cxx.c by doing the following in ./swig after bu= ilding libdai:

$(SWIG) -ocaml -c++ =C2=A0dai.= i
mv dai_wrap.cxx dai_wrap.cxx.c
sed -i -e 's/caml_= array_length/caml_array_len/g' dai_wrap.cxx.c

=
I got my swig and dai ml files by doing the following:

swig2.0 -ocaml -co dai.ml
swig2.0 -ocaml -co swig.mli

I build by doing the following:

ocaml setup.ml -configure
= ocaml setup.ml -build
=

I get the following error:


Solver failed:
=C2=A0 Ocamlbuild knows of no rules that apply to a target named ./libdai_= stubs.a. This can happen if you ask Ocamlbuild to build a target with the w= rong extension (e.g. .opt instead of .native) or if the source files live i= n directories that have not been specified as include directories.
Compilation unsuccessful after building 8 targets (8 cached) in 00:00:00.=
E: Failure("Command ''/usr/bin/ocamlbuild' ./li= bdai_stubs.a ./dlldai_stubs.so ./dai.cma ./dai.cmxa ./dai.a ./dai.cmxs -j 5= -tag debug' terminated with error code 6")

I = want to make sure that the actual target shared library that was produced b= y the libdai build file itself is linked against. But oasis is assuming I h= ave a _stubs target. I read in the documentation here that: "The usual i= diom is to append=C2=A0_stubs=C2=A0to the name."=C2=A0<= /span>
https://ocaml.o= rg/learn/tutorials/setting_up_with_oasis.html#Interfacing-with-C-= code

And I think that that is the source of the er= ror, but it isn't well explained. The ultimate things I originally want= ed was to be able to use libdai with both the utop or the bytecode interpre= ter and with fully compiled targets. I was going to make libdai a library a= nd then publicize it.

If anybody needs to replicat= e my issue, I have a docker container with this already.


--001a1142be568512330557c19118--