caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Georg Martius <georg.martius@web.de>
To: caml-list@inria.fr
Cc: Gerd Stolpmann <info@gerd-stolpmann.de>
Subject: Re: [Caml-list] Segmentationfault on 64bit when called from C
Date: Tue, 31 Jul 2012 16:03:31 +0200	[thread overview]
Message-ID: <4123447.LCvNL5nQdx@arges> (raw)
In-Reply-To: <1343739554.17140.423.camel@thinkpad>

On Tuesday 31 July 2012 14:59:14 Gerd Stolpmann wrote:
> Just a rough guess: The frametable is not initialized. Quite funny that
> it crashes so quickly. (Maybe more is not initialized, maybe the heap
> register, so it crashes at the first allocation.)
> 
> You cannot just link Ocaml code without adding the frametable. This is a
> description of how the stack and the CPU registers are used at runtime.
> If it is missing the OCaml runtime thinks that the Ocaml code is C code,
> and applies the wrong conventions.
> 
> The -shared switch generates a library that is prepared to be loaded
> with Dynlink. Dynlink registers the frametable.
> 
> You should consider using -output-obj to create a library that can be
> loaded without such tricks (see section 18.7.5 of the Ocaml manual).
ocamlopt -output-obj -o camlcode.o interface.c m1.ml
gcc -fPIC -g -Wall  -c -I/usr/local/lib/ocaml interface.c
gcc -fPIC -o test main.c camlcode.o  interface.o -L/usr/local/lib/ocaml -lunix 
-lm -lasmrun -ldl

works, but 
ocamlopt -o libmytest.so -output-obj  interface.c m1.ml
gcc -Wall main.c  -lmytest -o test
does not! Is it clear why it doesn't work?

So I get away with static linking for now.

Thanks!
  Georg

-- 
---- Georg Martius,  Tel: +49 177 6413311  -----
------- http://www.flexman.homeip.net ----------

  reply	other threads:[~2012-07-31 14:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-31 12:17 Georg Martius
2012-07-31 12:59 ` Gerd Stolpmann
2012-07-31 14:03   ` Georg Martius [this message]
2012-07-31 14:29     ` Xavier Leroy
2012-07-31 13:11 ` Anil Madhavapeddy

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=4123447.LCvNL5nQdx@arges \
    --to=georg.martius@web.de \
    --cc=caml-list@inria.fr \
    --cc=info@gerd-stolpmann.de \
    /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).