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 708157FA83 for ; Mon, 10 Apr 2017 15:02:40 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=nicolas.ojeda.bar@lexifi.com; spf=None smtp.mailfrom=nicolas.ojeda.bar@lexifi.com; spf=None smtp.helo=postmaster@vrout10.yaziba.net Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of nicolas.ojeda.bar@lexifi.com) identity=pra; client-ip=185.56.204.32; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="nicolas.ojeda.bar@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of nicolas.ojeda.bar@lexifi.com) identity=mailfrom; client-ip=185.56.204.32; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="nicolas.ojeda.bar@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@vrout10.yaziba.net) identity=helo; client-ip=185.56.204.32; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="postmaster@vrout10.yaziba.net"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3APNfkfhVYrmaxK6/9aqyLZZv2dkDV8LGtZVwlr6E/?= =?us-ascii?q?grcLSJyIuqrYbRePt8tkgFKBZ4jH8fUM07OQ6PG8HzRYqb+681k6OKRWUBEEjc?= =?us-ascii?q?hE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRo?= =?us-ascii?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HC4AuhmI0KBbHXwmNgBFGMKshM6TOzrk12CTSVeZ22yXq?= =?us-ascii?q?I5/jE0EpiqDYbFRoC3gbyOxj23HpNMZmxeD1CMFmrneJucVvcXbSKSPtdhkjsZ?= =?us-ascii?q?Vbi9GMcd0kS2vRL+jb5uJerd5gUVuY+lyd50+ajdnhY36TEyAd7O/XuKSjRSn2?= =?us-ascii?q?gPQ7Yt64d9rEB0/X0Py+Ashf1TEtha/LVOUAo2PNjWxvZSD93iWwzAONyOTQD1?= =?us-ascii?q?EZ2dHTgtQ4dpkJc1aEFnFoDn10ib0g=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CtAAAMgetYmCDMOLldHgYMGQYMgkOBR?= =?us-ascii?q?oELB4Nfm1kQl1YshB6BWgKDVAdDFAEBAQEBAQEBAQEBEgEBAQEBCAsLBigvgjM?= =?us-ascii?q?iAYJAAQICASMEUgULCQILNwICIhIBBQEcGYoHCAQBCYp6kRo/jASBbDqKYwEBA?= =?us-ascii?q?QEGAQEBAQEBIotAh1yCXwEEiSyTT4cAi1mCVIELjWKSOBQfgRMCNoEmW1YYBoQ?= =?us-ascii?q?ESYFxcwGJXgEBAQ?= X-IPAS-Result: =?us-ascii?q?A0CtAAAMgetYmCDMOLldHgYMGQYMgkOBRoELB4Nfm1kQl1Y?= =?us-ascii?q?shB6BWgKDVAdDFAEBAQEBAQEBAQEBEgEBAQEBCAsLBigvgjMiAYJAAQICASMEU?= =?us-ascii?q?gULCQILNwICIhIBBQEcGYoHCAQBCYp6kRo/jASBbDqKYwEBAQEGAQEBAQEBIot?= =?us-ascii?q?Ah1yCXwEEiSyTT4cAi1mCVIELjWKSOBQfgRMCNoEmW1YYBoQESYFxcwGJXgEBA?= =?us-ascii?q?Q?= X-IronPort-AV: E=Sophos;i="5.37,182,1488841200"; d="scan'208,217";a="219957056" Received: from vrout10.yaziba.net ([185.56.204.32]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 10 Apr 2017 15:02:39 +0200 Received: from mtaout10.int.yaziba.net (mtaout10.int.yaziba.net [10.4.20.36]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout10.yaziba.net (mx10.yaziba.net) with ESMTPS id 85C3551EB0 for ; Mon, 10 Apr 2017 15:02:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mtaout10.int.yaziba.net (Postfix) with ESMTP id A1765160276 for ; Mon, 10 Apr 2017 15:02:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at Received: from mtaout10.int.yaziba.net ([127.0.0.1]) by localhost (mtaout10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 9sG7r3OEY08X for ; Mon, 10 Apr 2017 15:02:38 +0200 (CEST) Received: from mail-qt0-f170.google.com (mail-qt0-f170.google.com [209.85.216.170]) by mtaout10.int.yaziba.net (Postfix) with ESMTPSA id 5BBF5160265 for ; Mon, 10 Apr 2017 15:02:38 +0200 (CEST) Received: by mail-qt0-f170.google.com with SMTP id v3so53818110qtd.3 for ; Mon, 10 Apr 2017 06:02:38 -0700 (PDT) X-Gm-Message-State: AFeK/H07lliP6mmVKFaCjetfST3/btr1dtsp9A/qLfXeAfMsaY/YlwQfT8roenfYbw0IzBnwgIyw/X4+lzk6bw== X-Received: by 10.237.49.195 with SMTP id 61mr57678653qth.82.1491829357239; Mon, 10 Apr 2017 06:02:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.49.66 with HTTP; Mon, 10 Apr 2017 06:02:16 -0700 (PDT) In-Reply-To: <1200659935.12485491.1491828956000.JavaMail.zimbra@edu.univ-fcomte.fr> References: <1200659935.12485491.1491828956000.JavaMail.zimbra@edu.univ-fcomte.fr> From: =?UTF-8?Q?Nicol=C3=A1s_Ojeda_B=C3=A4r?= Date: Mon, 10 Apr 2017 15:02:16 +0200 X-Gmail-Original-Message-ID: Message-ID: To: paul.lachat@edu.univ-fcomte.fr Cc: OCaml Mailing List Content-Type: multipart/alternative; boundary=94eb2c0b3618e762f2054ccf96c6 X-DRWEB-SCAN: ok X-VRSPAM-SCORE: -100 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrfeeliedruddvgdeiudcutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepjghfhfffkffuvfgtsegrtderredttdejnecuhfhrohhmpefpihgtohhljohspgfqjhgvuggrpgeumohruceonhhitgholhgrshdrohhjvggurgdrsggrrheslhgvgihifhhirdgtohhmqeenucffohhmrghinhepthgvshhtrdhmlhdpghhithhhuhgsrdgtohhmpdhsthgrtghkohhvvghrfhhlohifrdgtohhmnecukfhppedvtdelrdekhedrvdduiedrudejtdenucfrrghrrghmpehmohguvgepshhmthhpohhuth X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Subject: Re: [Caml-list] [Question] Compile and link program who use Toploop --94eb2c0b3618e762f2054ccf96c6 Content-Type: text/plain; charset=UTF-8 Dear Paul, You just need to link in ocamltoplevel.cma by adding it to the command-line ocamlc -I +compiler-libs ocamltoplevel.cma -o test.out test.ml (the compiler will be able to find this file thanks to the "-I +compiler-libs" flag). Cheers, Nicolas On Mon, Apr 10, 2017 at 2:55 PM, wrote: > Hello, > > I would like to use functions of the toplevel (https://github.com/ocaml/ > ocaml/blob/trunk/toplevel/toploop.ml) > > I've tried to compile this code just to understand how I can link the > toploop file with my program : > ____ > test.ml : > > let _ = > let lb = Lexing.from_string "let x = 10;;" in > let ppf = Format.std_formatter in > try > List.iter > (fun phr -> > if not (Toploop.execute_phrase false ppf phr) then raise Exit) > (!Toploop.parse_use_file lb) > with > | Exit -> () > | x -> Errors.report_error ppf x > > ____ > > I've test : > > [-] ocamlc -I +compiler-libs -o test.out test.ml > > [*] File "test.ml", line 1: > Error: Error while linking test.cmo: > Reference to undefined global `Toploop' > > ____ > > So I create test.cmo with : > [-] ocamlc -I +compiler-libs -c test.ml, but I don't know where to find > "toploop.cmo". > > I use Ocaml 4.03.0 with Opam. > In ".opam/4.03.0/lib/ocaml/compiler-libs/" I have "toploop.cmi", > "toploop.cmti" and "toploop.cmt", but no "toploop.cmo" to link to the > program. > > I've seen this file ".opam/4.03.0/lib/ocaml/compiler-libs/ocamltoplevel.cma", > but I don't know if it's usefull. > > I think it's possible to use Toploop. In this post, > https://stackoverflow.com/questions/33291754/eval-a-string-in-ocaml, they > seems to have find a way to compile a program who use Toploop. But I would > like, if possible, to avoid dependecys like ocamlbuild. > > ____ > > So, I would like to know how I can compile this program ? > --94eb2c0b3618e762f2054ccf96c6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Dear Paul,

You just need to link = in ocamltoplevel.cma by adding it to the command-line

= =C2=A0 ocamlc -I +compiler-libs ocamltoplevel.cma -o test.out test.ml

(the c= ompiler will be able to find this file thanks to the "-I +compiler-lib= s" flag).

Cheers,
Nicolas

On Mon, Apr 10,= 2017 at 2:55 PM, <paul.lachat@edu.univ-fcomte.fr> wrote:
Hello,
<= br>I would like to use functions of the toplevel (https://= github.com/ocaml/ocaml/blob/trunk/toplevel/toploop.ml)
I've tried to compile this code just to understand how I can link the = toploop file with my program :
____
test.ml :

let _ =3D
=C2=A0=C2=A0=C2=A0 let lb =3D= Lexing.from_string "let x =3D 10;;" in
=C2=A0=C2=A0=C2=A0 let= ppf =3D Format.std_formatter in
=C2=A0=C2=A0=C2=A0 try
=C2=A0=C2=A0= =C2=A0 List.iter
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (fun phr ->
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if not (Toploop.execute_phrase false p= pf phr) then raise Exit)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (!Toploop.parse_= use_file lb)
=C2=A0=C2=A0=C2=A0 with
=C2=A0=C2=A0=C2=A0 | Exit -> = ()
=C2=A0=C2=A0=C2=A0 | x -> Errors.report_error ppf x

____
I've test :

[-] ocamlc -I +compiler-libs -o test.out test.ml

[*] File "test.ml", line 1:
= =C2=A0=C2=A0=C2=A0 Error: Error while linking test.cmo:
=C2=A0=C2=A0=C2= =A0 Reference to undefined global `Toploop'

____

So I cre= ate test.cmo with :
[-] ocamlc -I +compiler-libs -c test.ml, but I don't know where to = find "toploop.cmo".

I use Ocaml 4.03.0 with Opam.
In &q= uot;.opam/4.03.0/lib/ocaml/compiler-libs/" I have "toploop.c= mi", "toploop.cmti" and "toploop.cmt", but no &quo= t;toploop.cmo" to link to the program.

I've seen this file = ".opam/4.03.0/lib/ocaml/compiler-libs/ocamltoplevel.cma"= ;, but I don't know if it's usefull.

I think it's possib= le to use Toploop. In this post, https://stackoverfl= ow.com/questions/33291754/eval-a-string-in-ocaml, they seems = to have find a way to compile a program who use Toploop. But I would like, = if possible, to avoid dependecys like ocamlbuild.

<= div>____

So, I would like to know how I can compile this = program ?

--94eb2c0b3618e762f2054ccf96c6--