A short example of implicitly linking the LPSolve library using CMake in C++

less than 1 minute read

This is a short note on getting lpsolve to work for the C++ api. It actually took me a while to get it working, so I thought this minimal example might perhaps help other people who are also having trouble. I got it working after reading the post at cprogramming which details how to compile code with a shared library: https://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html.

Check out the github repository for the code. Below I explain the three steps required to run the crop example after downloading the code.

Running the crop example:

  1. Make a directory called build to contain the output of cmake.
  2. Go to build and run cmake .. to generate the needed Makefiles.
  3. Run make to get the executable crop_example which can be executed.