caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Ben Jakb <ben.jakb@gmail.com>
Cc: matthieu.dubuget@gmail.com, caml-list@inria.fr
Subject: Re: [Caml-list] Shared libraries with ocamlopt callable from C	(without main())?
Date: Sun, 11 Jan 2009 17:27:51 +0100	[thread overview]
Message-ID: <496A1E07.9000108@inria.fr> (raw)
In-Reply-To: <fa75c1020901091722m3e249c37mb963b54c08cdb2db@mail.gmail.com>

> =====  $ cat ./main.c =====
>     #include <stdio.h>
>     #include "libadd5wrapper.h"
>     int main (int argc,char **argv){
>        printf("Gimme - %d \n", add5wrapper());

Should be add5wrapper(argv) -- as gcc's warnings told you.

>        return 0;
> }
> 
> Now I try to BUILD the whole thing:
> [...]
> Number 4 is where it breaks. I get a ton of errors and this is where
> it ends for me. Because # 4 is also the point where I definitely have
> no idea what I'm doing.

Two things:

- You're not linking in add5-prog.o as far as I can see

- In static mode, the Unix linker is very picky about the relative
  order of -lxxx arguments on the command-line.  For more information,
  see the Info pages for GNU ld.  You probably don't need -static anyway.

The following works:

ocamlopt -output-obj add5.ml -o add5-prog.o
gcc -I`ocamlc -where` -c add5wrapperlib.c
gcc -c main.c
gcc -o mainprog.opt main.o add5wrapperlib.o add5-prog.o \
       -L`ocamlc -where` -lasmrun -ldl -lm

Add "-static" to the last line if you know you really need it.

Hope this puts you back on tracks.

- Xavier Leroy


      parent reply	other threads:[~2009-01-11 16:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-08 22:45 Ben Aurel
2009-01-09  8:21 ` [Caml-list] " Matthieu Dubuget
2009-01-09  8:44   ` [Caml-list] Shared libraries with ocamlopt callable from C(without main())? RABIH.ELCHAAR
2009-01-10  1:22   ` [Caml-list] Shared libraries with ocamlopt callable from C (without main())? Ben Jakb
2009-01-10 11:50     ` Matthieu Dubuget
2009-01-10 15:28       ` Ben Jakb
2009-01-10 15:36         ` Matthieu Dubuget
2009-01-10 18:08           ` Ben Jakb
     [not found]       ` <200901101911.41594.monnier.florent@gmail.com>
2009-01-10 18:18         ` Ben Jakb
2009-01-11 16:27     ` Xavier Leroy [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=496A1E07.9000108@inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=ben.jakb@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=matthieu.dubuget@gmail.com \
    /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).