Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Shared libraries with ocamlopt callable from C (without main())?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-01-10 (15:36)
From: Matthieu Dubuget <matthieu.dubuget@g...>
Subject: Re: [Caml-list] Shared libraries with ocamlopt callable from C (without main())?
Ben Jakb a écrit :
> matthieu,
> thanks for the interesting answer.
> Unfortunately I can't build '', and it is a bit too
> advanced for me to understand.

If you have a > 3.10 version of ocaml, you don't need to compile

This is done automatically by ocamlbuild.

> Therefore I'll first go with your standard build commands. So - after
> modifing the sources according to your suggestions I run:
>     ocamlopt -c
>     ocamlopt -c add5wrapperlib.c
>     ocamlopt -o -ccopt -shared add5.cmx add5wrapperlib.o
>     ocamlc.opt -ccopt -Iinclude -c main.c
>     gcc -o maintest.native main.o -L. -Wl,-rpath=.
>     cp  lib/
>     ./maintest.native
> "maintest.native: add5wrapperlib.c:24: add5wrapper: Assertion `cbk' failed.
> Aborted"
> This is the referenced line:
>     $ sed -n 24p add5wrapperlib.c
> CAMLCBK_INIT(cbk, "add_five");
> Any ideas what' wrong here?

Yes ;-)

This is exactly why i use assert there.

I introduced a bug: the string in the C file is "add_five", while the
registered one in the ml file is "add five".

Hope this helps