Version française
Home     About     Download     Resources     Contact us    
Browse thread
Caml with main in C + .cmxa
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Florent Monnier <fmonnier@l...>
Subject: Caml with main in C + .cmxa
Hi,

I'm compiling the beginning of a small app written in OCaml but with the main 
which boot the app in C.
The OCaml app should also use a .cmxa lib, which is a binding to a C lib.

Without the .cmxa binding, compiling works good with this:

% ocamlopt -c  app.ml
% ocamlopt -output-obj -o mlobj.o  unix.cmxa  app.cmx
% gcc main.c  -o myapp.opt  mlobj.o \
        -I'/usr/local/lib/ocaml' \
        -L/usr/local/lib/ocaml \
        -lunix -lasmrun  -lm -ldl


But now I'm trying to figure out how to compile with the .cmxa
which is the binding to ImageMagick  (hump ~contrib:487)

To compile C code without caml pieces with the libMagick is done this way:
gcc `Magick-config --cflags --cppflags` app.c `Magick-config --ldflags --libs`

So here is my attempt to mix all together:

% ocamlopt -c  -I +libMagick  magick.cmxa   app.ml
% ocamlopt -output-obj -o mlobj.o unix.cmxa -I +libMagick magick.cmxa  app.cmx
(untill there, no error messages)

% gcc `Magick-config --cflags --cppflags`  main.c  -o myapp.opt  mlobj.o \
        -I'/usr/local/lib/ocaml' \
        -L/usr/local/lib/ocaml \
        -lunix -lasmrun  -lm -ldl \
        `Magick-config --ldflags --libs`

and then with this last command, I get about 200 errors like this:
--------------------
mlobj.o: In function `camlMagick__scale_1177':
: undefined reference to `fun_scaleimage'

mlobj.o: In function `camlMagick__sharpen_1136':
: undefined reference to `fun_sharpenimage'

mlobj.o: In function `camlMagick__blur_channel_1193':
: undefined reference to `fun_blurimagechannel'
--------------------

'fun_scaleimage' and the others are the names of the functions in
the C file of the OCaml-libMagick binding.



So what is the error I have done?
What should I correct to get the app compliled?


-- 
Thanks in advance
Florent Monnier