ocaml-glpk (glpk bindings) and OASIS

131 Views Asked by At

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

There are 2 best solutions below

0
On

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.

5
On

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.