Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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 'mycamlbuild.ml', 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
yourself myocamlbuild.ml.

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:
> 
> BUILD
>     ocamlopt -c add5.ml
>     ocamlopt -c add5wrapperlib.c
>     ocamlopt -o add5lib.native.so -ccopt -shared add5.cmx add5wrapperlib.o
>     ocamlc.opt -ccopt -Iinclude -c main.c
>     gcc -o maintest.native main.o -l:add5lib.native.so -L. -Wl,-rpath=.
> 
> EXECUTION
>     cp add5lib.native.so  lib/
>     ./maintest.native
> 
> ERROR
> "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