Steps to install and run lpsolve on a Mac

There are several ways to install lpsolve on a Mac. Here is one way.

  1. Go to the Sourceforge page for lpsolve.
  2. Click the big green Download button and, when prompted, save the downloaded file to your Downloads folder.

    This will download the latest source code for lpsolve to your machine. It does not take long: lpsolve is a small program. The file will have a name like lp_solve_5.5.2.11_source.tar.gz. (The 5.5.2.11 is a version; you might get a new version.)

  3. In Finder, navigate to your Downloads folder and double-click on the downloaded file.

    This will decompress the file and expand it into a set of folders. You should then see a folder named something like lp_solve_5.5 in your Downloads folder, together with the downloaded .gz file.

  4. Open the application Terminal on your machine.

    You may find it in the Utilities folder inside your applications folder.

  5. In Terminal, navigate to your Downloads folder. To do this, in the Terminal window, type the following commands, each followed by the enter key:
    cd
    cd Downloads
    cd lp_solve_5.5
    cd lp_solve
    sh ccc.osx
    
  6. This last command runs the shell script ccc.osx to set up lpsolve. You may see some warnings; you can probably ignore them.
    However, if you see an error like "xcrun: error: invalid active developer path", this most likely indicates that the lpsolve install script is looking for xcode command-line tools on your machine and cannot find them. In this case, try adding the xcode tools with this command:
    xcode-select --install
    It will take a few moments to this do installation. Then open a new terminal window, and try step #5 above again.
    These commands will create a sub-folder, bin containing the executable lp_solve (it may be in a further sub-folder, named something like osx64.)
  7. Navigate to the subfolder containing lp_solve by executing these commands in Terminal:
    cd bin
    cd osx64
    ls
    

    This last command, ls, will list the files in this folder: you should see lp_solve listed. This is the executable application.

  8. To test lpsolve and see that you've installed it, you will need a test lp file. You can use test.lp. Use Finder to put this file in the same folder with lp_solve.
  9. In Terminal, run lp_solve on this file with the command
    ./lp_solve test.lp
    
    lpsolve will run and give you the following result:
    Value of objective function: 4.61764706
    
    Actual values of the variables:
    x                         3.58824
    y                         1.02941
    

    This indicates that these values of x and y, the minimum sum x+y, 4.61764706, is achieved with x=3.58824 and y=1.02941 (approximately) while satisfying the specified constraints.

  10. Congratulations! You have succesfully installed lpsolve!

Additional notes