-1

Preface: I am new to OCaml, OPAM, and OASIS.

tldr question: How do I properly set up a package with opam that is not already available in the repository (I can't just do opam install X)? More details follow:

I am trying to include ocaml-glpk in an OCaml project. I installed ocaml-glpk just by running make and make install as stated in the README, and the given example compiles and runs correctly. However, I am using OASIS to generate the build system of my project, and I am not sure how to set it up. I have the same example (renamed to glpkExample.ml in a src folder) and the following in my _oasis file:

Executable "glpkExample"
  Path: src 
  MainIs: glpkExample.ml
  CompiledObject: best
  BuildDepends:
    glpk

After running oasis setup -setup-update dynamic, I run make and get the following error:

ocaml setup.ml -build 
Finished, 0 targets (0 cached) in 00:00:00.
+ /home/dimitrios/.opam/system/bin/ocamlfind ocamlopt -g -linkpkg -package glpk src/glpkExample.cmx -o src/glpkExample.native
File "_none_", line 1:
Error: Cannot find file /home/dimitrios/.opam/system/lib/glpk/glpk.cmxa
Command exited with code 2.
Compilation unsuccessful after building 4 targets (3 cached) in 00:00:00.
E: Failure("Command ''/usr/bin/ocamlbuild' src/glpkExample.native -tag debug' terminated with error code 10")
make: *** [build] Error 1

It seems the glpk library is missing a cmxa file needed to compile a native executable. I am not sure how to fix this. To compile glpkExample.ml correctly, my Makefile includes /home/dimitrios/.opam/system/lib/glpk and also uses the OCamlMakefile, which is extremely long and convoluted. Any help on setting this up with OASIS or how to get ocaml-glpk to work nicely with OASIS would be greatly appreciated.

Thanks!

2 Answers 2

0

This website is not appropriate for bug reports. You should really report it here.

The temporary solution is to use CompiledObject: byte to compile in bytecode.

0

If you're using opam then it is best to install application with it, not manually. Try to clean up your system and remove whatever you installed, and then do:

$ eval `opam config env`
$ opam install ocaml-glpk

Afterwards, if glpk is packaged in opam correctly, it should work with your setup, i.e., just with oasis's BuildDepends field and nothing more.

5
  • The version of ocaml-glpk on opam does not work with the version of glpk that I have, so I need to manually install it with opam somehow (I can't just do opam install ocaml-glpk). Is this done using opam pin, etc? OPAM's documentation isn't very beginner-friendly.
    – Dimitrios
    May 21, 2015 at 16:30
  • You can't install it with opam, because they do not have opam file in the upstream repository.
    – ivg
    May 21, 2015 at 16:41
  • So is my only option to manually package it as described here?
    – Dimitrios
    May 21, 2015 at 16:45
  • yep, I've just checked upstream Makefile, they indeed have only bytecode version. That means, that you can use CompiledObject: byte trick, as @Drup suggested.
    – ivg
    May 21, 2015 at 16:53
  • Ah, I see. I changed the Makefile as described in my edit of this question so that it compiles native code, and it seems to be working properly. I'm not sure why it isn't set to compile native code. Thanks for the help.
    – Dimitrios
    May 21, 2015 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.