On Thu, Nov 5, 2009 at 6:09 PM, David Allsopp <dra-n
...@metastack.com> wrote:
> Aaron Bohannon wrote:
>> I am quite confused by the whole process of compiling and installing
>> wrappers for C libraries. It seems like I can get things to work OK
>> without really knowing what I'm doing if everything is put and built
>> in a single directory. The hard part seems to be putting the right
>> files in the right places and getting the path arguments correct.
>> Then things stop working, and I have to really understand what's going
>> on, but the manual doesn't explain this part of the process in any
>> detail.
> Have a look at ocamlmklib in the manual - if it's available on your platform
> then it nicely hides away a lot of this.
> <snip - steps 1-4 are fine>
>> 5) Write "foo.ml" and use it to build "foo.cmxa" by running
>> ocamlopt -a -o foo.cmxa foo.ml
>> -ccopt -L/opt/local/lib -cclib -lfoo
>> -ccopt -L/usr/local/lib/ocaml/stubs -cclib -lfoo_stubs
> This command will also build foo.cmx, foo.a and foo.o
>> 6) Copy "foo.cmi" and "foo.cmxa" to their permanent location, let's
>> say "/usr/local/lib/ocaml/foo/"
> You should also copy foo.a to this directory which should fix the problem.
> foo.cmxa contains information required by OCaml but the actual code is in
> foo.a (as it's been natively compiled). Similarly, .cmx files contain
> information which ocamlopt needs but the actual code is in .o (or .obj)
> files. For native code, it's a code idea to copy the .cmx files too as it
> allows ocamlopt to do some inlining (I think that's right...)
>> 7) Write my file "bar.ml" that needs to use the library, and compile
>> it by running
>> ocamlopt -I /usr/local/lib/ocaml/foo -o bar foo.cmxa bar.ml
> This should now work without error.
> David
_______________________________________________