Skip to content

Conversation

@ktahar
Copy link
Owner

@ktahar ktahar commented Nov 10, 2021

Fixes (a part of) #3 by removing necessity of linking flags -cclib -lglpk on compilation of the apps using lp-glpk.
This is done by stop using dynamic ctypes.foreign and start using stub-generation feature of ctypes.
This patch also removes the hard-coding of C constants #defined in glpk.h.

Some references for stubgen features.

  • ocaml-yaml: directory structure and dune files are based on this
  • ocaml-fiu luv: simpler working examples
  • Some blog posts 1 2
  • There is ctypes stanza for new dune 3.0. However, I didn't use this as it is described experimental (refs. 1 and 2).

lp-gurobi is remained to use dynamic ctypes.foreign because build-time dependency on libgurobi (not open-source, limited access) will make some trouble.

- lp-glpk.consts exports #defined constants in glpk.h as OCaml module
- lp-glpk.types uses that and build structs and enum-ish ints
- We cannot use ctypes' enum function for glpk.h because there is no
  actual enum defs. They only use int args/fields that's assumed to take #defined values (unsafe!).
@ktahar ktahar merged commit d8e2ad3 into master Nov 10, 2021
@ktahar ktahar mentioned this pull request Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants