caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] OASIS help: link stublib to system lib and another caml lib
@ 2016-05-26 20:11 Olaf Hering
  2016-05-26 20:58 ` Christophe Troestler
  0 siblings, 1 reply; 5+ messages in thread
From: Olaf Hering @ 2016-05-26 20:11 UTC (permalink / raw)
  To: caml-list

The ocaml-fuse package as is does not build for bytecode target. I
updated the _oasis file as shown below and everything worked great. But
when feeding the resulting package to google-drive-ocamlfuse I got link
errors because ocaml-fuse was not linked to -lfuse and -lcamlidl. I
figured out how to link to fuse, its in $libdir so the compiler picks it
up.

But I can not figure out a generic way to link against -lcamlidl. This
package is in $libdir/ocaml, so I would have to exent CCLib: with
something like '-L $libdir/ocaml -lcamlidl'. This works if I force it to
be '-L/usr/lib64/ocaml -lcamlidl' for a 64bit build. But this would
break for 32bit builds.

Unfortunately I have not found the spot in the documentation where this
is explained. Appearently there is also no example covering such setup.

So how has the _oasis file to be changed to link to the system -lfuse
and to -lcamlidl in the ocaml installation path?

Olaf

$ cat ocaml-fuse/ocamlfuse-2.7.1_cvs2/_oasis:
OASISFormat:      0.4
Name:             ocamlfuse
Version:          2.7.1-cvs2
Synopsis:         OCaml bindings for FUSE (Filesystem in UserSpacE)
Description:      OCaml bindings for FUSE (Filesystem in UserSpacE)
Authors:          Vincenzo Ciancia
LicenseFile:      LICENSE
License:          GPL
OCamlVersion:     >= 3.12
FindlibVersion:   >= 1.5
Homepage:         http://sourceforge.net/apps/mediawiki/ocamlfuse
#
BuildTools:       ocamldoc, ocamlbuild

Library Fuse
  Path:            lib
  BuildDepends:    unix, threads, bigarray, camlidl
  FindlibName:     Fuse
  Modules:         Fuse, Fuse_bindings, Fuse_lib, Result, Unix_util
  CSources:        Fuse_util.c, Unix_util_stubs.c, Fuse_bindings_stubs.c, Fuse_bindings.h
  CCOpt:           -g -O2 -fPIC -DPIC -w
  CCLib:           -lfuse -L/usr/lib64/ocaml -lcamlidl


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

* Re: [Caml-list] OASIS help: link stublib to system lib and another caml lib
  2016-05-26 20:11 [Caml-list] OASIS help: link stublib to system lib and another caml lib Olaf Hering
@ 2016-05-26 20:58 ` Christophe Troestler
  2016-05-27  8:14   ` Olaf Hering
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe Troestler @ 2016-05-26 20:58 UTC (permalink / raw)
  To: Olaf Hering; +Cc: caml-list

Hi,

On 2016-05-26, Olaf Hering wrote:
> 
> But I can not figure out a generic way to link against -lcamlidl. This 
> package is in $libdir/ocaml, so I would have to exent CCLib: with 
> something like '-L $libdir/ocaml -lcamlidl'. This works if I force it 
> to be '-L/usr/lib64/ocaml -lcamlidl' for a 64bit build. But this would 
> break for 32bit builds.
> [...]
> Library Fuse
>   Path:            lib
>   BuildDepends:    unix, threads, bigarray, camlidl
>   FindlibName:     Fuse
>   Modules:         Fuse, Fuse_bindings, Fuse_lib, Result, Unix_util
>   CSources:        Fuse_util.c, Unix_util_stubs.c, 
>   Fuse_bindings_stubs.c, Fuse_bindings.h
>   CCOpt:           -g -O2 -fPIC -DPIC -w
>   CCLib:           -lfuse -L/usr/lib64/ocaml -lcamlidl

"-lfuse" is needed because it is the library you bind to but 
"-L/usr/lib64/ocaml -lcamlidl" should be handled by "camlidl" 
(specifically by `ocamlfind query camlidl`/com.cma).

Otherwise, if you have a way of detecting the right path, you can add 
some code in setup.ml that define a variable (that will end up in 
setup.data) and get its value back in myocamlbuild.ml to add some flags. 
See the following example that detects the path to give to clang so that 
it links the gfortran library:
https://github.com/Chris00/ocaml-odepack/blob/master/setup.ml#L68
https://github.com/Chris00/ocaml-odepack/blob/master/myocamlbuild.ml#L7
https://github.com/Chris00/ocaml-odepack/blob/master/myocamlbuild.ml#L36

If you have time to distill this example into some generic instructions 
and submit a PR, that would be nice.  https://github.com/ocaml/oasis

Best,
C.

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

* Re: [Caml-list] OASIS help: link stublib to system lib and another caml lib
  2016-05-26 20:58 ` Christophe Troestler
@ 2016-05-27  8:14   ` Olaf Hering
  2016-05-27 23:22     ` Christophe Troestler
  0 siblings, 1 reply; 5+ messages in thread
From: Olaf Hering @ 2016-05-27  8:14 UTC (permalink / raw)
  To: Christophe Troestler; +Cc: caml-list

On Thu, May 26, Christophe Troestler wrote:

> "-lfuse" is needed because it is the library you bind to but
> "-L/usr/lib64/ocaml -lcamlidl" should be handled by "camlidl" (specifically
> by `ocamlfind query camlidl`/com.cma).

Are you saying that something should automatically generate and pass the
-L option to the compiler with the provided _oasis file? For me nothing
like that happens if I add just '-lfuse -lcamlidl' to CcOpt:
execve("/usr/bin/gcc", ["gcc", "-shared", "-o", "lib/dllFuse_stubs.so",
"lib/Fuse_util.o", "lib/Unix_util_stubs.o", "lib/Fuse_bindings_stubs.o",
"-lfuse", "-lcamlidl"]

For the time being my workaround is to use '-L/usr/lib64/ocaml
-L/usr/lib/ocaml' which appearently fixes 32 and 64bit builds.

To me it looks like "OCamlbuild additional flags:" needs to be set.
Is there a way to pass this via 'ocaml setup.ml -configure'?

> Otherwise, if you have a way of detecting the right path, you can add some
> code in setup.ml that define a variable (that will end up in setup.data) and
> get its value back in myocamlbuild.ml to add some flags. See the following
> example that detects the path to give to clang so that it links the gfortran
> library:
> https://github.com/Chris00/ocaml-odepack/blob/master/setup.ml#L68

I think thats a very bad advice. Are you suggesting to ignore the 'DO
NOT EDIT' of each generated setup.ml? Being able to regenerate the files
required for building from scratch is essential.

Olaf

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

* Re: [Caml-list] OASIS help: link stublib to system lib and another caml lib
  2016-05-27  8:14   ` Olaf Hering
@ 2016-05-27 23:22     ` Christophe Troestler
  2016-06-01 16:25       ` Olaf Hering
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe Troestler @ 2016-05-27 23:22 UTC (permalink / raw)
  To: Olaf Hering; +Cc: caml-list


On 2016-05-27, Olaf Hering wrote:
> 
> On Thu, May 26, Christophe Troestler wrote:
> 
> > "-lfuse" is needed because it is the library you bind to but
> > "-L/usr/lib64/ocaml -lcamlidl" should be handled by "camlidl" 
> > (specifically
> > by `ocamlfind query camlidl`/com.cma).
> 
> Are you saying that something should automatically generate and pass 
> the
> -L option to the compiler with the provided _oasis file? For me 
> nothing
> like that happens if I add just '-lfuse -lcamlidl' to CcOpt:
> execve("/usr/bin/gcc", ["gcc", "-shared", "-o", 
> "lib/dllFuse_stubs.so",
> "lib/Fuse_util.o", "lib/Unix_util_stubs.o", 
> "lib/Fuse_bindings_stubs.o",
> "-lfuse", "-lcamlidl"]
> 
> For the time being my workaround is to use '-L/usr/lib64/ocaml 
> -L/usr/lib/ocaml' which appearently fixes 32 and 64bit builds.
> 
> To me it looks like "OCamlbuild additional flags:" needs to be set. 
> Is there a way to pass this via 'ocaml setup.ml -configure'?

You wan only pass static options via _oasis.  If you can get the path to 
camlidl — which the camlidl library should provide, try "ocamlfind query 
camlidl" — then you can use the trick below to pass it to ocamlbuild and 
set appropriate flags.

> > https://github.com/Chris00/ocaml-odepack/blob/master/setup.ml#L68
> 
> I think thats a very bad advice. Are you suggesting to ignore the 'DO 
> NOT EDIT' of each generated setup.ml? Being able to regenerate the 
> files required for building from scratch is essential.

The edits are *outside* the OASIS section so are preserved upon 
regeneration — this is the purpose of the delimiters, this not bad 
advice at all! :-)

Best,
C.

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

* Re: [Caml-list] OASIS help: link stublib to system lib and another caml lib
  2016-05-27 23:22     ` Christophe Troestler
@ 2016-06-01 16:25       ` Olaf Hering
  0 siblings, 0 replies; 5+ messages in thread
From: Olaf Hering @ 2016-06-01 16:25 UTC (permalink / raw)
  To: Christophe Troestler; +Cc: caml-list

On Sat, May 28, Christophe Troestler wrote:

> You wan only pass static options via _oasis.  If you can get the path to
> camlidl — which the camlidl library should provide, try "ocamlfind query
> camlidl" — then you can use the trick below to pass it to ocamlbuild and set
> appropriate flags.

I'm new to all this.
I took the time to create an _oasis file for camlidl in its rpm
specfile, shown below. As you can see the source needs some header file.
But the "runtime" directory is not in the search path, and appearently
there is no generic way to specify the "-I$PWD/runtime". How is this
supposed to be handled?

...
%build
pushd compiler
sed -e 's|%%%%CPP%%%%|cpp|' config.mlp > config.ml
popd
tee _oasis <<_EOF_
OASISFormat: 0.4
Name:        camlidl
Version:     %{version}
Authors:     Xavier Leroy
LicenseFile: LICENSE
License:     QPL-1.0 and LGPL-2.0
Synopsis:    Stub code generator for OCaml
Plugins:     META(`oasis version`)
BuildTools:  ocamlbuild

Library com
  Path: lib
  Install: true
  Modules: Com

Library camlidl
  Path: runtime
  Install: true
  Datafiles: camlidlruntime.h (\$standard_library/caml)
  CSources: idlalloc.c
  CCOpt: -I$PWD/runtime -Wall -O2 -g

Executable camlidl
  Install: true
  Path: compiler
  MainIs: main.ml
  CompiledObject: best
_EOF_

oasis setup
ocaml setup.ml -configure \
	--destdir %{buildroot} \
	--libdir %{_libdir} \
	--bindir %{_bindir} \
	--prefix %{_prefix}
ocaml setup.ml -build
...


Olaf

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

end of thread, other threads:[~2016-06-01 16:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-26 20:11 [Caml-list] OASIS help: link stublib to system lib and another caml lib Olaf Hering
2016-05-26 20:58 ` Christophe Troestler
2016-05-27  8:14   ` Olaf Hering
2016-05-27 23:22     ` Christophe Troestler
2016-06-01 16:25       ` Olaf Hering

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).