caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* compiling a clib from further away
@ 2007-06-27 13:56 Andrew Warshaver
  2007-06-27 14:08 ` [Caml-list] " Andrew Warshaver
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Warshaver @ 2007-06-27 13:56 UTC (permalink / raw)
  To: caml-list

I am trying to compile a clib (with the eventual hope of it making its 
way into a compiled ocaml lib).  It is working fine if I am in the 
specific directory; but if I move too far out it fails.  My directories 
are like /../janebase/lib/cephes/  The c files live in cephes.

$ cat lib/cephes/libjane_stubs.clib
bdtr.o
btdtr.o
chbevl.o
...
$ cat _tags
<sexp> or <lib>: include

$ cat myocamlbuild.ml
open Ocamlbuild_plugin
open Command

let headers = ["lib/cephes/mconf.h"; "lib/cephes/protos.h"];;

dispatch begin function
   | After_rules ->
       dep ["compile"; "c"] headers;
   | _ -> ()
end

$ ocamlbuild lib/cephes/libjane_stubs.a
+ /usr/local/home/godi310/godi/bin/ocamlmklib -o /cephes/libjane_stubs 
lib/cephes/bdtr.o lib/cephes/btdtr.o lib/cephes/chbevl.o 
lib/cephes/chdtr.o lib/cephes/const.o lib/cephes/drand.o 
lib/cephes/expx2.o lib/cephes/fdtr.o lib/cephes/gamma.o 
lib/cephes/gdtr.o lib/cephes/igam.o lib/cephes/igami.o 
lib/cephes/incbet.o lib/cephes/incbi.o lib/cephes/kolmogorov.o 
lib/cephes/main.o lib/cephes/mtherr.o lib/cephes/nbdtr.o 
lib/cephes/ndtr.o lib/cephes/ndtri.o lib/cephes/pdtr.o 
lib/cephes/polevl.o lib/cephes/stdtr.o lib/cephes/unity.o
/usr/bin/ld: cannot open output file /cephes/dlllibjane_stubs.so: No 
such file or directory
collect2: ld returned 1 exit status
Command exited with code 2.

However, when I move one directory closer,

$ cd lib
[awarshaver@nyc-qws-029 lib]$ cat myocamlbuild.ml
open Ocamlbuild_plugin
open Command

let headers = ["cephes/mconf.h"; "cephes/protos.h"];;

dispatch begin function
   | After_rules ->
       dep ["compile"; "c"] headers;
   | _ -> ()
end
[awarshaver@nyc-qws-029 lib]$ ocamlbuild cephes/libjane_stubs.a
+ /usr/local/home/godi310/godi/bin/ocamlc.opt -c cephes/main.c
cephes/main.c: In function ‘main’:
cephes/main.c:9: warning: control reaches end of non-void function
Finished, 49 targets (0 cached) in 00:00:02.

Any ideas?

Thanks,
Andrew


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] compiling a clib from further away
  2007-06-27 13:56 compiling a clib from further away Andrew Warshaver
@ 2007-06-27 14:08 ` Andrew Warshaver
  2007-06-27 14:48   ` Nicolas Pouillard
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Warshaver @ 2007-06-27 14:08 UTC (permalink / raw)
  To: caml-list



Andrew Warshaver wrote:
> I am trying to compile a clib (with the eventual hope of it making its 
> way into a compiled ocaml lib).  It is working fine if I am in the 
> specific directory; but if I move too far out it fails.  My directories 
> are like /../janebase/lib/cephes/  The c files live in cephes.
> 
> $ cat lib/cephes/libjane_stubs.clib
> bdtr.o
> btdtr.o
> chbevl.o
> ...
> $ cat _tags
> <sexp> or <lib>: include
> 
> $ cat myocamlbuild.ml
> open Ocamlbuild_plugin
> open Command
> 
> let headers = ["lib/cephes/mconf.h"; "lib/cephes/protos.h"];;
> 
> dispatch begin function
>   | After_rules ->
>       dep ["compile"; "c"] headers;
>   | _ -> ()
> end
> 
> $ ocamlbuild lib/cephes/libjane_stubs.a
> + /usr/local/home/godi310/godi/bin/ocamlmklib -o /cephes/libjane_stubs 

by the way, obviously the culprit is in this -o, it should have lib/, is 
this a ocamlbuild bug?

> lib/cephes/bdtr.o lib/cephes/btdtr.o lib/cephes/chbevl.o 
> lib/cephes/chdtr.o lib/cephes/const.o lib/cephes/drand.o 
> lib/cephes/expx2.o lib/cephes/fdtr.o lib/cephes/gamma.o 
> lib/cephes/gdtr.o lib/cephes/igam.o lib/cephes/igami.o 
> lib/cephes/incbet.o lib/cephes/incbi.o lib/cephes/kolmogorov.o 
> lib/cephes/main.o lib/cephes/mtherr.o lib/cephes/nbdtr.o 
> lib/cephes/ndtr.o lib/cephes/ndtri.o lib/cephes/pdtr.o 
> lib/cephes/polevl.o lib/cephes/stdtr.o lib/cephes/unity.o
> /usr/bin/ld: cannot open output file /cephes/dlllibjane_stubs.so: No 
> such file or directory
> collect2: ld returned 1 exit status
> Command exited with code 2.
> 
> However, when I move one directory closer,
> 
> $ cd lib
> [awarshaver@nyc-qws-029 lib]$ cat myocamlbuild.ml
> open Ocamlbuild_plugin
> open Command
> 
> let headers = ["cephes/mconf.h"; "cephes/protos.h"];;
> 
> dispatch begin function
>   | After_rules ->
>       dep ["compile"; "c"] headers;
>   | _ -> ()
> end
> [awarshaver@nyc-qws-029 lib]$ ocamlbuild cephes/libjane_stubs.a
> + /usr/local/home/godi310/godi/bin/ocamlc.opt -c cephes/main.c
> cephes/main.c: In function ‘main’:
> cephes/main.c:9: warning: control reaches end of non-void function
> Finished, 49 targets (0 cached) in 00:00:02.
> 
> Any ideas?
> 
> Thanks,
> Andrew
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] compiling a clib from further away
  2007-06-27 14:08 ` [Caml-list] " Andrew Warshaver
@ 2007-06-27 14:48   ` Nicolas Pouillard
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Pouillard @ 2007-06-27 14:48 UTC (permalink / raw)
  To: Andrew Warshaver; +Cc: caml-list

On 6/27/07, Andrew Warshaver <awarshaver@janestcapital.com> wrote:
>
>
> Andrew Warshaver wrote:
> > I am trying to compile a clib (with the eventual hope of it making its
> > way into a compiled ocaml lib).  It is working fine if I am in the
> > specific directory; but if I move too far out it fails.  My directories
> > are like /../janebase/lib/cephes/  The c files live in cephes.
> >
> > $ cat lib/cephes/libjane_stubs.clib
> > bdtr.o
> > btdtr.o
> > chbevl.o
> > ...
> > $ cat _tags
> > <sexp> or <lib>: include
> >
> > $ cat myocamlbuild.ml
> > open Ocamlbuild_plugin
> > open Command
> >
> > let headers = ["lib/cephes/mconf.h"; "lib/cephes/protos.h"];;
> >
> > dispatch begin function
> >   | After_rules ->
> >       dep ["compile"; "c"] headers;
> >   | _ -> ()
> > end
> >
> > $ ocamlbuild lib/cephes/libjane_stubs.a
> > + /usr/local/home/godi310/godi/bin/ocamlmklib -o /cephes/libjane_stubs
>
> by the way, obviously the culprit is in this -o, it should have lib/, is
> this a ocamlbuild bug?
>

Indeed, it seems to be a bug. In order to give the library name
without the "lib" prefix, ocamlbuild cuts the given pathname on the
substring "lib". The bad news is that it's not dummy programming bug,
it's more abou the expressiveness of ocamlbuild rules.

Indeed there are roughly two rules for libs.

... ~prods:["lib%(libname).a"; "dll%(libname).so"] ...

... ~prods:["%(path)/lib%(libname).a"; "%(path)/dll%(libname).so"] ...

And for now I can specify more precise rules. So with your lib/
directory you fall in the first one.

An safe workaround is to rename your lib/ dir.

-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-06-27 14:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-27 13:56 compiling a clib from further away Andrew Warshaver
2007-06-27 14:08 ` [Caml-list] " Andrew Warshaver
2007-06-27 14:48   ` Nicolas Pouillard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).