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
-output-obj and shared libraries?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-09-09 (16:36)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: -output-obj and shared libraries?
> My target platform is Linux/x86.  
> Is it possible to create a .so object from ocaml?   

It depends what you want to put in the shared library and how you
want to use it.

>From your mention of the -output-obj option, I infer that you'd like
to build a shared library that contains some Caml code, some C
wrappers around the Caml code, and a copy of the Caml runtime system.
This is easy to do.  Referring to the example at the end of the
"Interfacing C with Objective Caml" chapter, you'd do:

        ocamlc -custom -output-obj -o modcaml.o
        ocamlc -c modwrap.c
	gcc -shared -Wl,-soname, -o \
                modwrap.o modcaml.o /usr/local/lib/ocaml/libcamlrun.a

and then install in a public place as usual.  Then you
can dynamically link against libmod using -lmod or dlopen().

If your question is about building shared libraries of Caml code that
can be linked dynamically against other Caml code, we don't know yet
how to do this.  A Caml program can load bytecode Caml object files at
run-time using the Dynlink library, but that's not quite the same

Best regards,

- Xavier Leroy