From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id pA1FgxFA028264 for ; Tue, 1 Nov 2011 16:42:59 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AscBAK8SsE7RVdY2kGdsb2JhbABCqCeBDAgiAQEBAQkJDQcUBCGBcgEBAQQSAiwBOAEDDAEFBQsDOB8DEgEFARwGExoIh2iYDQqONIUNiS0CBQqDOIVFBIwqh2WNMz2BSYIn X-IronPort-AV: E=Sophos;i="4.69,438,1315173600"; d="scan'208";a="115981824" Received: from mail-bw0-f54.google.com ([209.85.214.54]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 01 Nov 2011 16:42:54 +0100 Received: by bkbzs2 with SMTP id zs2so6508604bkb.27 for ; Tue, 01 Nov 2011 08:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=q/kM2KAYb5RpSYTTDWayw24uFAotq1L2Hrp7UOHJuh4=; b=GoD+L1rQO7SM4piEtjuBYF7POWo/zDCAGC1QZfl3u1CuLI++egxGt9j+Jq70UK7tv4 0wPgUPtu0lLl5xNIWj80SypbuNFC/gEe9JdfuzmykuC91OkqYwiEAgUy0L9u0p6wqjgA KGl/haVaG/n0T5kAL4UJSWsbvtYToEchsKBtM= Received: by 10.204.139.84 with SMTP id d20mr100165bku.13.1320162173109; Tue, 01 Nov 2011 08:42:53 -0700 (PDT) MIME-Version: 1.0 Sender: david.mentre@gmail.com Received: by 10.204.10.19 with HTTP; Tue, 1 Nov 2011 08:42:22 -0700 (PDT) In-Reply-To: References: From: David MENTRE Date: Tue, 1 Nov 2011 16:42:22 +0100 X-Google-Sender-Auth: lc4tVw9oPxQGMxGJCgc9ud7JYIU Message-ID: To: David Allsopp Cc: Andreea Costea , "caml-list@inria.fr" Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] Standalone executable Hello, 2011/10/31 David Allsopp : > Compile it with ocamlopt instead of ocamlc - Chapter 11 of the manual (which it's a little surprising you hadn't got to, if you've been looking for a few days)... http://caml.inria.fr/pub/docs/manual-ocaml/manual025.html > > "This chapter describes the OCaml high-performance native-code compiler ocamlopt, which compiles Caml source files to native code object files and link these object files to produce standalone executables." Depending on the level of independence one might want on the underlying system, ocamlopt alone might not me enough, as C libraries are still dynamically linked. Option "-ccopt -static" is needed to produce real statically linked binaries. Some parts of the OCaml runtime may not work when statically linked, YMMV. Example: $ cat hello.ml open Format let _ = printf "Hello@\n" $ ocamlopt hello.ml $ ./a.out Hello $ ldd ./a.out linux-vdso.so.1 => (0x00007fff127e7000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007faf7ca80000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007faf7c87c000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007faf7c4e7000) /lib64/ld-linux-x86-64.so.2 (0x00007faf7cd2a000) $ ocamlopt -ccopt -static hello.ml $ ./a.out Hello $ ldd ./a.out not a dynamic executable $ file ./a.out ./a.out: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.15, not stripped Best regards, david