caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Andreea Costea <andre.costea@gmail.com>
To: David MENTRE <dmentre@linux-france.org>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Standalone executable
Date: Wed, 2 Nov 2011 15:28:41 +0800	[thread overview]
Message-ID: <CADxQj2d9-s21GPz-Utay+7yQrgUeLHA7x-qOR5BGYU5WpV+1rQ@mail.gmail.com> (raw)
In-Reply-To: <CAC3Lx=YR9qRnH4kJ2HLqPOq0b9SThFku4L-=t9AuTsaPYWrCzw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1948 bytes --]

Thank you all for the answers. Finally i managed to make my whole project
portable. I didn't manage to successfully create it since the beginning
because the my makefile was still using ocamlc for certain files, and I
didn't notice this before.

Regards,
Andreea

On Tue, Nov 1, 2011 at 11:42 PM, David MENTRE <dmentre@linux-france.org>wrote:

> Hello,
>
> 2011/10/31 David Allsopp <dra-news@metastack.com>:
> > 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
>

[-- Attachment #2: Type: text/html, Size: 2808 bytes --]

      reply	other threads:[~2011-11-02  7:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-31 12:02 Andreea Costea
2011-10-31 15:27 ` David Allsopp
2011-10-31 18:31   ` Gerd Stolpmann
2011-11-01 15:42   ` David MENTRE
2011-11-02  7:28     ` Andreea Costea [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADxQj2d9-s21GPz-Utay+7yQrgUeLHA7x-qOR5BGYU5WpV+1rQ@mail.gmail.com \
    --to=andre.costea@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dmentre@linux-france.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).