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 02DD0801CD for ; Mon, 28 Aug 2017 03:51:48 +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-f42.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.42; 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.42 as permitted sender) identity=mailfrom; client-ip=209.85.215.42; 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-f42.google.com) identity=helo; client-ip=209.85.215.42; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="kennethadammiller@gmail.com"; x-sender="postmaster@mail-lf0-f42.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3A59E3OxDlAEw/jiI6SjeEUyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSP3zo8bcNUDSrc9gkEXOFd2Crakb26yL6+jJYi8p39WoiDg6aptCVhsI24?= =?us-ascii?q?09vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6i760TlHERz6MUJo?= =?us-ascii?q?PenvAcaGhM2y06W2+obPSwROnju0J71oekaYtwLU4+obh41vNqZ54xfApzNteu?= =?us-ascii?q?BSyHkgcVGemRDx+se58Jdm9iVUv/8738FFWKT+Oa8/SOoLX3wdL2kp6Ziz5lH4?= =?us-ascii?q?RgyV6y5EXw=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AUAgBzdqNZhirXVdFcHAEBBAEBCgEBF?= =?us-ascii?q?wEBBAEBCgEBgkSBT4EVB4NwgTaYfIFxd4F5jXiHUDCFFwKDXAdDFAEBAQEBAQE?= =?us-ascii?q?BAQEBEgEBAQgLCwgoL4IzIoJDAQEBAQIBIx0BGx4DAQsGAwILDSoCAiEBAREBB?= =?us-ascii?q?QEcBhOKGAEDDQgQlBGRG0CMC4IFBQEcgwkFg1cKGScNV4NEAQoBAQEcAgYSgxi?= =?us-ascii?q?CAoMxgnM1gleCS4JmgmEFiVUlDocZgWeNIDyHVod6hHaCElqBFId1hnOMSRCIG?= =?us-ascii?q?xUfgRU2gS4yISR4gjWCECofgg8kNgGKXAEBAQ?= X-IPAS-Result: =?us-ascii?q?A0AUAgBzdqNZhirXVdFcHAEBBAEBCgEBFwEBBAEBCgEBgkS?= =?us-ascii?q?BT4EVB4NwgTaYfIFxd4F5jXiHUDCFFwKDXAdDFAEBAQEBAQEBAQEBEgEBAQgLC?= =?us-ascii?q?wgoL4IzIoJDAQEBAQIBIx0BGx4DAQsGAwILDSoCAiEBAREBBQEcBhOKGAEDDQg?= =?us-ascii?q?QlBGRG0CMC4IFBQEcgwkFg1cKGScNV4NEAQoBAQEcAgYSgxiCAoMxgnM1gleCS?= =?us-ascii?q?4JmgmEFiVUlDocZgWeNIDyHVod6hHaCElqBFId1hnOMSRCIGxUfgRU2gS4yISR?= =?us-ascii?q?4gjWCECofgg8kNgGKXAEBAQ?= X-IronPort-AV: E=Sophos;i="5.41,439,1498514400"; d="scan'208,217";a="288509413" Received: from mail-lf0-f42.google.com ([209.85.215.42]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 28 Aug 2017 03:51:46 +0200 Received: by mail-lf0-f42.google.com with SMTP id z12so13261603lfd.3 for ; Sun, 27 Aug 2017 18:51:46 -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=Kp80TnDhC1kAMvZWYqo+iBhUb8L3TiZLDNIJneVMrCc=; b=jFIBAa9VzePf2QeiwRFzxdYB9p0AcvLnXfUZCHiDfT+ULQIowYdXFJnXkZoBX0qBuh 5EFNfUMwMBwdpTBOwvNiA+zDRnqYsWReBDLzbgD2cBkiysFf1Twlw8+2+86iEd5rSc63 YuwmW1swbZAiyh5Gcw4yZuV5M4djd2zi9ZnZbKoSCQGUcz/gtwloJQtlhbDAUW4c6V48 SMdQTFQkohvauLkvRNPEuGu0XTS/cGHue0goZwwKV/3jmd2IwhgejOQvk4uMDY0tJsK6 lPhQX01GyYrjAuNn8r8nhT+F/GfGtsGlYHviGCVzuePvCcRYtod81HhX4lLppErhZTns cumg== 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=Kp80TnDhC1kAMvZWYqo+iBhUb8L3TiZLDNIJneVMrCc=; b=ry9e3jVOgEHzbWf+4pOUIWTuNI2SlaiTGjwroEC+TVqdnNJkka0JT6w0ghb/x34KIP A/gQOb2GNq+uLJLj8QKgvJGL/u37wPxX6Fiw5sXERhdYBOj3tkXUkHp6Vsg+ukfvDR12 fupM0nxxxFD4Mos1M1qLT6nWs1irnmX/QyXO0MKTGsQzFJGWr7e4hbToHkv9IkepKU94 IsQRM7wVBzITrprzQC1zfZudcHkUNZXA1KhGZtCebtKXtc5JsN961rZQ2e5GPD15NIh4 xuBLdZ8O86bA1T/8YNP4kYfcI6KP+fLcwGCceMbzMVLTQM+UWUduUZFBVYc2hJExijcD jEQQ== X-Gm-Message-State: AHYfb5gKyNAv0bnAQJwX6/KQmqqbx2KOizcp2EX9Ae2DiyJ0bu7+fTrl lbI/Xe7h40Izj5q0EhMy/nrwHx5zVHSzjKM= X-Received: by 10.46.64.212 with SMTP id r81mr1797881lje.97.1503885105489; Sun, 27 Aug 2017 18:51:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.46.81.18 with HTTP; Sun, 27 Aug 2017 18:51:44 -0700 (PDT) In-Reply-To: References: From: Kenneth Adam Miller Date: Sun, 27 Aug 2017 21:51:44 -0400 Message-ID: To: caml users Content-Type: multipart/alternative; boundary="94eb2c1a61127eed370557c68988" Subject: Re: [Caml-list] oasis and C wrapper --94eb2c1a61127eed370557c68988 Content-Type: text/plain; charset="UTF-8" Ok I think I found the source of the error - this was in the _build/_log: ### Starting build. Backtrace: - Failed to build the target libdai_stubs.a - Building libdai_stubs.a: - Failed to build all of these: - Building libdai_stubs.cmx: - Failed to build all of these: - Building libdai_stubs.ml: - Failed to build all of these: - Building libdai_stubs.mly - Building libdai_stubs.mll - Building libdai_stubs.mlpack - Building libdai_stubs.mllib - Building libdai_stubs.clib # Compilation unsuccessful. The problem is that libdai_stubs.a is already built, and ocamlbuild is trying to build it again! Also, I followed the with-c oasis example to a T, and theirs never tried to build .cmx/mllib/mlpack/mly/mli suffixed auto-generated C source file targets. So why would it try and do that with mine?? I found that changing the library name of mine in my _oasis causes oasis/ocamlbuild to search for an appropriately named .ml file. But that doesn't happen in the with-c example, and not only that, the with-c example doesn't have a with-c.ml file anyway?! Also my issue has been replicated in two different dockers, stale mated on a Mac, and then also within an ubuntu vm. I can't make this opam package until I get oasis and ocamlbuild to work together. On Sun, Aug 27, 2017 at 3:56 PM, Kenneth Adam Miller < kennethadammiller@gmail.com> wrote: > 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_extern >> al_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. >>> >> >> > --94eb2c1a61127eed370557c68988 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ok I think I found the source of the error - this was in t= he _build/_log:

### Starting build.
Backtrace:
<= div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 - Failed to build the target libdai_stubs.a
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 - Building libdai_stubs.a:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - Fa= iled to build all of these:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 - Building libdai_stubs.cmx:
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - Failed to build all of these:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -= Building libdai_stubs.ml:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 - Failed to build all of these:
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 - Building libdai_stubs.mly
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 - Building libdai_stubs.mll
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - Building libdai_stubs.mlpack
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - Building libdai_stub= s.mllib
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - Building l= ibdai_stubs.clib
# Compilation unsuccessful.

=
The problem is that libdai_stubs.a is already built, and ocamlbuild is= trying to build it again! Also, I followed the with-c oasis example to a T= , and theirs never tried to build .cmx/mllib/mlpack/mly/mli suffixed auto-g= enerated C source file targets. So why would it try and do that with mine??= I found that changing the library name of mine in my _oasis causes oasis/o= camlbuild to search for an appropriately named .ml file. But that doesn'= ;t happen in the with-c example, and not only that, the with-c example does= n't have a with-c.ml file anyway?! Als= o my issue has been replicated in two different dockers, stale mated on a M= ac, and then also within an ubuntu vm.

I can't make this opam pa= ckage until I get oasis and ocamlbuild to work together.=C2=A0
<= div class=3D"gmail_extra">
On Sun, Aug 27, 20= 17 at 3:56 PM, Kenneth Adam Miller <kennethadammiller@gmail.com<= /a>> wrote:
Ok= , so I got the with-c example to build by running -configure before I built= with ocaml setup.ml -bui= ld, 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 s= teps, and I have know what calls ocamlbuild should be making to get the .cm= a 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 s= hould 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 fo= und 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:

=

And I'm tr= ying 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&#= 39;m building a pair of companion oasis build spec and opam package setup f= or a C library. libdai I figured out how to get swig and oasis to build mos= t 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 t= hat is the product of the project I'm trying to wrap. I can't convi= nce oasis 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 In= stall: =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 CSo= urces: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dai_wrap.cxx.c
= =C2=A0 CCOpt: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-g -xc= ++ "-I../../include"


With a fr= esh clone of libdai, I get dai_wrap.cxx.c by doing the following in ./swig = after building libdai:

$(SWIG) -ocaml -c++ = =C2=A0dai.i
mv dai_wrap.cxx dai_wrap.cxx.c
sed -i -e &#= 39;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= :
=C2=A0 Ocamlbuild knows of no rules that apply to a target name= d ./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 f= iles live in directories that have not been specified as include directorie= s.
Compilation unsuccessful after building 8 targets (8 cached) i= n 00:00:00.
E: Failure("Command ''/usr/bin/ocamlbuil= d' ./libdai_stubs.a ./dlldai_stubs.so ./dai.cma ./dai.cmxa ./dai.a ./da= i.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 a= ssuming I have a _stubs target. I read in the documentation here that: &quo= t;= The usual idiom is to append=C2=A0_stubs=C2=A0to the name.&q= uot;=C2=A0
= http= s://ocaml.org/learn/tutorials/setting_up_with_oasis.html#Interfac= ing-with-C-code

And I think that that is the sourc= e of the error, but it isn't well explained. The ultimate things I orig= inally wanted was to be able to use libdai with both the utop or the byteco= de 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.



--94eb2c1a61127eed370557c68988--