Linking glpk with or-tools on unix

Following the change on SCIP, here is the new procedure to compile and link GLPK with or-tools

This currently applies to unix only:

First download the latest glpk archive (4.61 at the time of this post).

Untar, cd into the glpk directory

on linux:
  ./configure --prefix=<install_path> --with-pic
  make install

on mac OS X:
  ./configure --prefix=<install_path>
  make CFLAGS='--mmacosx-version-min=10.8'
  make install
then add:
  UNIX_GLPK_DIR=<install_path> in or-tools/Makefile.local

recompile or-tools:
  make clean
  make cc

test it:
  run bin/integer_programming and bin/linear_programming. Both must display glpk runs.

I have no easy solution for glpk on windows currently, still investigating.


  1. Step 2 on macOS Sierra gives me an error, this is the output:
    /Library/Developer/CommandLineTools/usr/bin/make all-recursive
    Making all in src
    /bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I. -I./amd -I./api -I./bflib -I./cglib -I./colamd -I./env -I./minisat -I./misc -I./mpl -I./proxy -I./simplex -I./zlib --mmacosx-version-min=10.8 -MT libglpk_la-bfd.lo -MD -MP -MF .deps/libglpk_la-bfd.Tpo -c -o libglpk_la-bfd.lo `test -f 'bfd.c' || echo './'`bfd.c
    libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I. -I./amd -I./api -I./bflib -I./cglib -I./colamd -I./env -I./minisat -I./misc -I./mpl -I./proxy -I./simplex -I./zlib --mmacosx-version-min=10.8 -MT libglpk_la-bfd.lo -MD -MP -MF .deps/libglpk_la-bfd.Tpo -c bfd.c -fno-common -DPIC -o .libs/libglpk_la-bfd.o
    clang: error: unsupported option '--mmacosx-version-min=10.8'
    make[2]: *** [libglpk_la-bfd.lo] Error 1
    make[1]: *** [all-recursive] Error 1
    make: *** [all] Error 2

    1. Solved! The error is in your command above: the correct option is '-mmacos-version-min' with only one '-' and not '--mmacos-version-min'.


  2. Hi Laurent,

    Can you remind me what is the difficult solution for gplk on windows for or-tools?

    I try to add the .gz on \dependencies\archives, before recompile.
    But the example bin\csintegerprogramming.exe still don't find GLPK (but ok with SCIP, thanks for your explanations !!).


  3. I am not at all an expert at recompiling libraries. However I find it a little odd that when I compile the ortools the headers are dispersed around in the subdirectories unlike the binary version. For example when I used the binary version I could just tell the compiler to look for header files in /include while for the compiled version I had to add a path to /dependencies/install/include for integral_types.h and to /ortools/gen for parameters.pb.h.

    I must say that it does not make things easy for an average joe like me. But hey, the integer_programming example compiles and runs with GLPK, so that's the essential thing I guess !

  4. Hello,

    I am using ORtools on python.
    I am working using the Windows subshell.
    Therefore I am on Ubuntu.
    I would like to use the GLPK solver.
    I have install glpk.
    Now I would like to add: UNIX_GLPK_DIR= in or-tools/Makefile.local.
    Yet I cannot find the directory or-tool.
    I feel like it is because I am using python.
    Please could you help me ?
    Kind regards


Post a Comment

Popular posts from this blog

Changing the way we link with SCIP

Heads up, upcoming incompatibility in the CP/Routing library