COIN-OR::LEMON - Graph Library

How to Compile a Code Using LEMON

LEMON is basically a large collection of C++ header files plus a small static library. If you want to use LEMON from your own code, you must somehow let the compiler know where to find them. There are three ways for doing it.

  • Firstly, you can install LEMON to your system. You can either install some prebuilt binary version or install it from source (don't worry, it's easy).
    • If you install it system-wide on Unices (Linux, OSX, AIX etc.), then the compiler will automatically find LEMON, thus you can simply compile your code like this (assuming GCC compiler):
      g++ -O2 -lemon
    • If you want to use an installed LEMON on Windows or a user-local installed version on Unices, you must explicitly tell the location of the header files and the lib to the compiler. Please consult the documentation of your compiler on how to do it.
    For further instructions, see the corresponding sections of the LEMON tutorial.
  • Secondly, if you want to compile a single .cc file very fast (or with the prospect that your algorithm eventually will be migrated into the core LEMON itself), you can download LEMON and add your code to it. For this, put the .cc file into the contrib/ subdirectory, adjust contrib/CMakeLists.txt and compile it according to Build with CMake guide. Of course you can omit the final installation step.
  • Thirdly, you can use the LEMON project template either with an installed or a project local version of LEMON. This template is a preconfigured CMake build environment for LEMON based C++ projects. It is especially recommended for larger project with several source codes (and even multiple executables), but it pretty easy to set up for small applications, too.

The second and the third options have two important advantages.

  • Firstly, they are platform independent solutions, CMake will create proper Makefiles or solution/project files for the IDE of your choice, on all platforms and without any editing of the configuration file.
  • Secondly, you can choose a specific version of LEMON for your project which you can carry with your code thus you do not depend on an installed version.
Last modified 10 years ago Last modified on 01/11/14 22:40:01