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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 9E720801CD for ; Sun, 27 Aug 2017 07:19:13 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=kennethadammiller@gmail.com; spf=Pass smtp.mailfrom=kennethadammiller@gmail.com; spf=None smtp.helo=postmaster@mail-lf0-f51.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of kennethadammiller@gmail.com) identity=pra; client-ip=209.85.215.51; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kennethadammiller@gmail.com"; x-sender="kennethadammiller@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of kennethadammiller@gmail.com designates 209.85.215.51 as permitted sender) identity=mailfrom; client-ip=209.85.215.51; receiver=mail3-smtp-sop.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 (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-lf0-f51.google.com) identity=helo; client-ip=209.85.215.51; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kennethadammiller@gmail.com"; x-sender="postmaster@mail-lf0-f51.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AflyWEBM2+1b5zLCUVLYl6mtUPXoX/o7sNwtQ0KIM?= =?us-ascii?q?zox0K/T/rarrMEGX3/hxlliBBdydsK0UzbeO+4nbGkU+or+5+EgYd5JNUxJXwe?= =?us-ascii?q?43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6a8TWO6msZExD7fRdu?= =?us-ascii?q?K/7uUtrZhsGzkuSz4IH7YgNShTP7b6kkfzusqgCElcQQh4Z+Ku4YxhLM6l5Jf+?= =?us-ascii?q?Bb3ys8Jl+VmRvg5s689Ztm8iBUtugJ+MtJUKG8dKM9G+8LRA86Onw4sZW4/SLI?= =?us-ascii?q?ShGCsyMR?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AMBgAQVaJZhjPXVdFcHAEBBAEBCgEBF?= =?us-ascii?q?wEBBAEBCgEBgkSBEAE+gRUHg3CBNph9gXF3j3GHUDCFFwKDXAdDFAEBAQEBAQE?= =?us-ascii?q?BAQEBEgEBAQgLCwgoL4IzIoJEAQICASMdARseAwELBgMCCzcCAiEBAREBBQEcB?= =?us-ascii?q?hOKGAEDDQgQkn6RG0CMC4IFBQEcgwkFg1UKGScNV4NEAQEBBwEBAQEcAgYSgxi?= =?us-ascii?q?CAoMxgnM1gleCS4JmgmEFiVUlDocZgWeNIDyHVod6hHaCElqBFId1hnOMSYgrF?= =?us-ascii?q?R+BFTaBLjIhJHiCNYIQKh+CDyQ2AYsfAQEB?= X-IPAS-Result: =?us-ascii?q?A0AMBgAQVaJZhjPXVdFcHAEBBAEBCgEBFwEBBAEBCgEBgkS?= =?us-ascii?q?BEAE+gRUHg3CBNph9gXF3j3GHUDCFFwKDXAdDFAEBAQEBAQEBAQEBEgEBAQgLC?= =?us-ascii?q?wgoL4IzIoJEAQICASMdARseAwELBgMCCzcCAiEBAREBBQEcBhOKGAEDDQgQkn6?= =?us-ascii?q?RG0CMC4IFBQEcgwkFg1UKGScNV4NEAQEBBwEBAQEcAgYSgxiCAoMxgnM1gleCS?= =?us-ascii?q?4JmgmEFiVUlDocZgWeNIDyHVod6hHaCElqBFId1hnOMSYgrFR+BFTaBLjIhJHi?= =?us-ascii?q?CNYIQKh+CDyQ2AYsfAQEB?= X-IronPort-AV: E=Sophos;i="5.41,434,1498514400"; d="scan'208,217";a="235424054" Received: from mail-lf0-f51.google.com ([209.85.215.51]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 27 Aug 2017 07:19:12 +0200 Received: by mail-lf0-f51.google.com with SMTP id d202so11546837lfd.5 for ; Sat, 26 Aug 2017 22:19:12 -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=A7mOf9W1+hTKueWGQz4tHVAGPKF8fwEZjY7JhP4nDU8=; b=iWJoJiCtGfYF6tkDdCUTDmwJ4r031iV0zvvThWxcWcdTordLip7l27ogMKhgOQ6Rpr jTAfovkeEGC10/adCAxRc5OIyXMvMmOe30SPwvWDpv781fG7PwJQli2eMBvNowsuiFqo ShR0vTIqyup9iJmo3YT8z/5Ddd5Mg9202ry7qvb5ABDnF86Uxdo483Hb9e37GAClwOm6 BBjyKt7h6djDhXZEO93F1PanJ/0PqDe7IQ4eQoxFkfNaZpBSa/ZgoOkH4uTo4GcfzLW0 nyk3KZN8ljlrNO1wAiwRq/iABtHbq4XgU/OeYiLC7WYJoW04Wl2aXIKRLVOhxbvFCN1Z TmHg== 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=A7mOf9W1+hTKueWGQz4tHVAGPKF8fwEZjY7JhP4nDU8=; b=VLZnkx+lTBMJz32Rk4u5ea8rD31R7hF7WtK7kjB4LmafbUrQnXsKsdhX3J9pdE9TMG HVnkuVfQ9AVpvJ1Ccsb7DPr8Z648tZ8JcYTwitamEl3BXP+/QF2DhewWUQ3JlRMiH5Tr e63zTT+0LFkau09L9dXASTmIoxFaShugoVSWOdLjbh43vNl5rtZWhZWmTSKFOwbOsS1y tDg3C8PSpKsDVvsoEft54gXP0sPztTAgjRWykTMn9pRKlLiI98knuu9k+ZxHAfnqAk6E CbK9Knf+3uOf23XHgXJL4cgWm/wNwEuuhnyBQp2u1xtuYsWQqmw0g8+pkdf8u+wy1mi7 4rbg== X-Gm-Message-State: AHYfb5iR/pqUlfLNy5CVM8c613v4MPrQG6slaRMwywnR12hiKUf2JYxw lKl77Hw4RD+Quqg3ZPW52U4WnuygDSI/dCc= X-Received: by 10.46.80.20 with SMTP id e20mr1131224ljb.71.1503811151288; Sat, 26 Aug 2017 22:19:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.46.81.18 with HTTP; Sat, 26 Aug 2017 22:19:10 -0700 (PDT) In-Reply-To: References: From: Kenneth Adam Miller Date: Sun, 27 Aug 2017 01:19:10 -0400 Message-ID: To: caml users Content-Type: multipart/alternative; boundary="f403045fb74a7b60400557b551e4" Subject: Re: [Caml-list] oasis and C wrapper --f403045fb74a7b60400557b551e4 Content-Type: text/plain; charset="UTF-8" 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. > --f403045fb74a7b60400557b551e4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 ref= erence 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 t= hat raw directory in isolation, that it fails with a similar error I had be= en getting earlier. I looked around and found these:



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 trou= ble getting oasis to not generate _stubs targets that aren't found. The= re 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= "
=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 CCOpt: =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-g -xc++ "-I../../include"

With a fresh clone of libdai, I get dai_wrap.cx= x.c by doing the following in ./swig after building libdai:

<= /div>
$(SWIG) -ocaml -c++ =C2=A0dai.i
mv dai_wrap.cxx da= i_wrap.cxx.c
sed -i -e 's/caml_array_length/caml_array_l= en/g' dai_wrap.cxx.c

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

swig2.0 -ocaml -co dai.ml
swig2.0 -ocaml -c= o swig.ml
swig2.= 0 -ocaml -co swig.mli

I build by doing the f= ollowing:

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


I get the following e= rror:


Solver failed:
=C2=A0 Ocamlbuild knows of n= o rules that apply to a target named ./libdai_stubs.a. This can happen if y= ou ask Ocamlbuild to build a target with the wrong extension (e.g. .opt ins= tead of .native) or if the source files live in directories that have not b= een specified as include directories.
Compilation unsuccessful af= ter building 8 targets (8 cached) in 00:00:00.
E: Failure("C= ommand ''/usr/bin/ocamlbuild' ./libdai_stubs.a ./dlldai_stubs.s= o ./dai.cma ./dai.cmxa ./dai.a ./dai.cmxs -j 5 -tag debug' terminated w= ith error code 6")

I want to make sure that the ac= tual target shared library that was produced by the libdai build file itsel= f is linked against. But oasis is assuming I have a _stubs target. I read i= n the documentation here that: "The usual idiom is to append=C2=A0_stubs=C2=A0to the name."=C2=A0
https://ocaml.org/learn/tutorials/set= ting_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 u= se libdai with both the utop or the bytecode interpreter and with fully com= piled targets. I was going to make libdai a library and then publicize it.<= /div>

If anybody needs to replicate my issue, I have a d= ocker container with this already.

--f403045fb74a7b60400557b551e4--