From: Mauricio Fernandez Date: 2007-10-19T03:09:54+09:00 Subject: Re: rocaml 0.6.0: fast, easy Ruby extensions in Objective Caml On Fri, Oct 19, 2007 at 12:26:04AM +0900, Daniel Berger wrote: > > You didn't > > make opt.opt > > (or make world.opt) when you built ocaml-3.10.0, did you? > > Ok, I did make world.opt and reinstalled. Then I rebuilt camlp5 with > "transitional". Now it seems I'm missing some header files: > > >make > ocamldep.opt rubyOCamlUtil.ml > .depend > cc -I. -I/usr/local/lib/ruby/1.8/sparc-solaris2.10 -I/usr/local/lib/ > ruby/1.8/sparc-solaris2.10 -I. -KPIC -g -c foo_rocaml_wrapper.c > "foo_rocaml_wrapper.c", line 14: cannot find include file: mlvalues.h> [...] > > I don't think OCaml's installation instructions could be any more > confusing. What option did I miss? I'm sorry for all the issues and appreciate your patience. The basic problem is that I'm using Debian and everything Just Works(TM) with its OCaml packages, so it is harder for me to anticipate problems like those you ran into. I see that you're using Solaris, which adds further uncertainty because I'm not sure its linker can build shared objects with non-PIC code [1]. Some magic incantations in the form of $LDFLAGS might be required. You're stepping on new ground :) The missing headers should be in /usr/local/lib/ocaml/3.10.0/caml (or maybe /usr/local/lib/ocaml/caml; in my system I have a symlink from /usr/include/caml to /usr/lib/ocaml/3.10.0/caml, which is why this never happened to me). The extension should build correctly after symlinking or applying this one-line patch: Thu Oct 18 19:14:58 CEST 2007 Mauricio Fernandez * rocaml_extconf.rb: add ocaml_native_lib_path to the INCFLAGS (-Idir). diff -rN -u -w old-rocaml/rocaml_extconf.rb new-rocaml/rocaml_extconf.rb --- old-rocaml/rocaml_extconf.rb 2007-10-18 19:25:49.000000000 +0200 +++ new-rocaml/rocaml_extconf.rb 2007-10-18 19:25:49.000000000 +0200 @@ -43,6 +43,8 @@ exit end +$INCFLAGS << " -I#{ocaml_native_lib_path}" + maybe_opt = lambda{|x| opt = "#{x}.opt"; system(opt) ? opt : x } if OCAML_PACKAGES.empty? then Note that the extension you're building ("foo") isn't complete. It includes the wrappers but not the OCaml implementations of the corresponding functions; in fact, it is only meant to serve as the extconf.rb template for new extensions. You can find the actual examples under examples/: * marshal: 3-line specialized marshallers that can be over 3 times faster than Ruby's Marshal (the largest speedup is achieved with float arrays) * tree: a 30-line RB tree with 3X faster lookup than RBTree (you'll need rbtree if you want to run the benchmarks in test_tree.rb) * oo, records, variants: show how abstract types, records and variants are converted between Ruby and OCaml. Abstract types become objects, records turn into hashes with symbol keys and variants are mapped to symbols or arrays. Thank you, [1] According to http://gcc.gnu.org/ml/gcc/1999-05n/msg00376.html SunOS and Solaris will quite happily build .so from non-PIC objects - they just don't "share" very well as the relocations cause copy-on-write and hence private pages. So there's a good chance it will work. -- Mauricio Fernandez - http://eigenclass.org