Monday, July 5, 2010

Installing Curb with Ruby 1.9.1 in Windows

Disclaimer: This is about how I installed curb in Windows XP. This is probably not the only way and certainly not the best way. I'm not a Windows developer (I just play one on TV) and haven't done any work with C in an embarrassingly long time. I'll be happy to help with any problems, but please don't expect me to be able to fix this at 5pm on Friday when your production machine decides to blow up.

Now that we got that out of the way...

How I finally got curb to install in Windows.
  1. Install the latest Ruby installer and DevKit.
    The finer points of doing that are outside the scope of this post, so if you have trouble with those things I'd reccommend this tutorial, the DevKit Howto and the excellent RubyInstaller mailing list.

    Just for the record, I'm using the latest as of the time I'm writing this: ruby-1.9.1-p429 and devkit-3.4.5r3-20091110.7z.

  2. Get libcurl.
    I, again, am using the latest as of the time I'm writing this: 7.21.0. If you need a different version for whatever reason, the libcurl downloads page has a few different versions available, so make sure to get the one for mingw32 and that you get libcurl and not plain-old curl.

    With that downloaded, I extracted the .zip file to the root of my C:\ drive. The location you put this is important for the next steps.

  3. Put the curl binaries in your path.
    My preferred way is to add the libcurl \bin folder to the Windows path, so that typing 'path' at a Windows command prompt gives a result like this:


    Other things you can do here are copy the libcurl .dll files into your ruby's \bin folder (or anywhere else in the PATH) but I think that's kinda lame.

  4. Install curb.
    The magic incantation I found for this was the following:

    gem install curb -- --with-curl-lib=C:\curl-7.21.0-devel-mingw32\bin --with-curl-include=C:\curl-7.21.0-devel-mingw32\include

    Every other combination of flags and paths resulted in compilation errors, so you've been warned. Also, you'll need to change the curl paths if you decided to install to a different place or with a different version.

  5. Test it.
    Here's a very simple script that will load curb and GET a url:
    require 'curb'

    c =
    c.url = ""
    puts c.body_str.size

    # Output:
    # 574

Did this work for you? Let me know in the comments!