[Osi] [OSI] [Request For Comments] Discovering libraries at runtime

Christophe-Marie Duquesne chm.duquesne at gmail.com
Thu Mar 29 09:36:42 EDT 2012


Hi Osi list,

I would like to discuss here a patch I submitted to the Osi tracker
[1]. My goal here is to share some technical knowledge and to answer
any question that may arise.

First, what does this patch do:
It adds the ability to load on demand - rather than linking to - the
cplex, xpress and gurobi libraries. With this feature, you do not need
to rebuild Osi when you install cplex, gurobi or xpress, because your
Osi build permanently support them. The only configuration the user is
left with is either to put the targeted solver library in a standard
library path, or to specify its full path through some environment
variable (LAZYLPSOLVERLIBS_CPLEX_LIB_PATH,
LAZYLPSOLVERLIBS_XPRESS_LIB_PATH or LAZYLPSOLVERLIBS_GUROBI_LIB_PATH).
Please also note that this patch does not require any change in the
Osi API. Programs already written using Osi won't require any
modification.

With this patch, I hope to make the Osi packaging easier and more
useful. Some distributions do provide an Osi build, but this build
never supports cplex, gurobi nor xpress (while they are quite
popular). That is why I always end up compiling my own version. A
pre-packaged version that supports all these solvers out of the box
would probably make Osi more popular, and bring users/developers.
Furthermore, this removes conditional compilations, macros, and
contributes to make the build system simpler. No more need to tell
where cplex is when building, just assume it is there and if it is
not, an exception will be thrown at runtime in the
Osi{Cpx,Xpr,Grb}SolverInterface constructor.

To write this patch, I implemented a set of libraries called
lazylpsolverlibs [2]. Their purpose is to provide Osi (or any other
program that needs to implement a similar feature) with this ability,
while hiding the complexity of loading libraries and importing their
symbols. I have been working hard on this project to make it simple to
use, portable, and packaged (a windows build and two linux packages,
deb and rpm, are available). You can explore and read a tutorial on
the project page.

I am willing to answer any question about this patch and/or about
lazylpsolverlibs here.

[1]: https://projects.coin-or.org/Osi/attachment/ticket/95/runtime_library_discovery.patch
[2]: https://code.google.com/p/lazylpsolverlibs/

Cheers,
Christophe-Marie Duquesne


More information about the Osi mailing list