Installing GLPK on a Mac

programming

Obsolation note:

Thanks to Dave Coleman’s comment I found out that glpk is available through homebrew now! So you just need these 2 steps to get glpk now:

  1. homebrew
  2. brew install glpk

If you still want to read on, the old way is still here…

So you want copy-paste instructions to install GLPK on your Macbook? Here are the steps:

  1. Download the latest version of GLPK from http://www.gnu.org/software/glpk/#downloading
  2. Optional: Follow the instructions to verify the download (you might need to get GNU Privacy Guard or gpg for this. You can get it at http://gnupg.org)
  3. Say it’s downloaded to your “Downloads” directory, go there and execute the following commands (using the terminal)
    cd ~/Downloads
    tar -xzf glpk-4.43.tar.gz
    ./configure --prefix=/usr/local # see note [1]
    make
    sudo make install
        
  4. At this point, you should have GLPK installed. Verify it:
    which glpsol
    /usr/local/bin/glpsol
        
  5. … and try help:
    glpsol --help
        

Now that you are all set-up, read up this excellent introduction using GLPK: http://www.ibm.com/developerworks/linux/library/l-glpk1

Notes:
[1]: HiveLogic article on why using /usr/local is better
[2] If you want MySQL support (or something “extra”) check out the INSTALL file in the package

13 Comments

13 Comments

  1. Ali Rizvi  •  Feb 26, 2010 @18:47

    I am glad you did not have to do darwin ports for this.

  2. Arnab  •  Mar 2, 2010 @10:41

    Yeah – all the top links that come up on Google for “glpk on mac” point to using Ports – and those processes don’t even work anymore. So wrote this up – hope it helps someone in the future.

  3. polyn  •  Oct 12, 2010 @07:31

    for some reason if i type the “make” command it returns with this:

    -bash: make: command not found

    so the sudo wont work either. what’s wrong?

  4. Arnab  •  Oct 12, 2010 @10:04

    @polyn – sounds like you don’t have any developer tools installed on your Mac. What OS is it running (10.6 Snow Leopard)?

    One way to get these tools installed is to get XCode. You can get it here: https://developer.apple.com/technologies/xcode.html. You’ll need to register for an Apple Developer account – unless you already have one. Unless you want to pay them (and develop software for iOS/Mac) you can sign up for an Apple Dev account: http://developer.apple.com/programs/register

    Once you install XCode you should have “make” installed. To check run “which make” on the Terminal. If you still don’t see it “echo $PATH” and paste it here.

    Let us know how it goes.

  5. polyn  •  Oct 14, 2010 @04:32

    it’s working now..
    xcode was missing. i thought i had it but since the last osx reinstall i havent had it..
    thanks for your help

  6. rajath  •  Apr 4, 2011 @21:51

    hi, im getting this err in 3rd step

    78-ca-39-b5-a4-c8:Downloads newstein$ ./configure –prefix=/usr/local
    -bash: ./configure: No such file or directory

    kindly help, im nw to dis

  7. Arnab  •  Apr 5, 2011 @08:56

    Hi Rajath,

    Looks like the tar you downloaded is not good. Run this:
    $> tar -tvf glpk-4.43.tar.gz

    … and see if you see the “configure” file there.

    If it’s not there you probably have a bad download – try downloading again.

    Otherwise let me know more details about your setup (Mac OS version, GLPK version, where you downloaded from etc.)

  8. rajath  •  Apr 5, 2011 @16:11

    hi Arnab,

    I am able to run configure cmmnd bt still nt able to run Pulp/ GLPK prgms.

    1)wen i run the prgm, it shows no glpk module.

    2)also wen i run make command as instructed in Install file ,
    i am getting error like

    newstein$ make install
    Making install in include
    make[2]: Nothing to be done for `install-exec-am’.
    test -z “/usr/local/include” || .././install-sh -c -d “/usr/local/include”
    /usr/bin/install -c -m 644 ‘glpk.h’ ‘/usr/local/include/glpk.h’
    install: /usr/local/include/glpk.h: Permission denied
    make[2]: *** [install-includeHEADERS] Error 71
    make[1]: *** [install-am] Error 2
    make: *** [install-recursive] Error 1

    using ur cmmnds given above, their is no err , but prgms r nt executed…

    kindly help…

    My mac is v10.6.6
    nd gplk i downloaded from

    http://webscripts.softpedia.com/dyn-postdownload.php?p=27868&t=0&i=1

  9. Arnab  •  Apr 8, 2011 @20:54

    Please follow the instructions step-by-step – you need to do a “sudo make install”, not “make install”.

  10. Crista Madan  •  Sep 9, 2011 @22:34

    After I in the beginning commented at http://www.arnab-deka.com/posts/2010/02/installing-glpk-on-a-mac I clicked the – Notify me when new comments are added- checkbox and after this whenever a new remark is put in at Arnab's Universe » Installing GLPK on a Mac page, I receive few e-mail utilizing the similar remark. Possibly there is by any means it is possible to eliminate myself from that services? Thanks alot :) !

  11. Dave Coleman  •  Sep 19, 2011 @15:45

    I began following these instructions but then realized I could install glpk with Homebrew https://github.com/mxcl/homebrew

  12. Arnab  •  Sep 19, 2011 @16:35

    @Crista: Sorry about that. I will find a way to not to spam you!

    @Dave: Thanks! Just tried it through brew and it worked! I’ll add a big honking note on top of this post.

  13. firdevs  •  Nov 12, 2011 @21:08

    Hi, I olud not figure out the first (new) way so I tried older way you provided. I installed Xcode already but I still there is something wrong that it says:

    No targets specified and no makefile found.

    Any help will be appreciated, thank you!

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>