views:

44

answers:

1

I have a OCaml library with lots of classes I need some translator to make it from OCaml lib a C lib so to be able to use its methods. How to do such thing? How to port OCaml lib into lib Acsessable from C code?

+2  A: 

Generally porting from one language to another is a very manual process. You read through the original source and convert it, largely by hand, to the new language. There may be tools to help you out along the way, but you're still going to need to get your hands dirty a lot.

That said, it's possible to call OCaml functions from a C program (and vice versa). This will still require writing a bunch of code but might prove to be easier (you only need to understand the library, not how the library works).

Here is a blog post on how to do this. In addition to that blog post, you can check out the official docs, which focus far more on calling C code from OCaml (the opposite of what you want to do). That can be found here.

There is also a chapter in the O'Reilly book on this.

Niki Yoshiuchi
Is there a way to get from ocamlopt not object file (camlcode.o) that can be linked to C code but real C code (C source files)?
Blender
Are you asking if ocamlopt will compile OCaml into c code like GHC does for Haskell? To the best of my knowledge you can't do that, but I'm not sure.
Niki Yoshiuchi