* Caml with main in C + .cmxa
@ 2006-02-03 15:13 Florent Monnier
2006-02-03 18:41 ` [Caml-list] " Florent Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Florent Monnier @ 2006-02-03 15:13 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Caml with main in C + .cmxa
2006-02-03 15:13 Caml with main in C + .cmxa Florent Monnier
@ 2006-02-03 18:41 ` Florent Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Florent Monnier @ 2006-02-03 18:41 UTC (permalink / raw)
To: caml-list
> > % 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:
> > [...]
Indeed, the solution was to give the stubs of the binding to gcc:
% ls /usr/local/lib/ocaml/libMagick/
dllmagick_stubs.so libmagick_stubs.a magick.a magick.cma magick.cmi
magick.cmxa magick.mli
% 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` \
-L/usr/local/lib/ocaml/libMagick \
-lmagick_stubs
++ Thanks a lot to Jonathan and Rabih for your help !
--
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-03 18:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-03 15:13 Caml with main in C + .cmxa Florent Monnier
2006-02-03 18:41 ` [Caml-list] " Florent Monnier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox