[CurbForWindows]
Installing curb-0.1.4 Ruby gem under Windows
Here's how I finally got curb running in my Windows Ruby on Rails development environment. It's a little complicated but it does work…
- Note that I'm using the Visual Studio 2008 (MSVC++ 9.0) compiler and the standard curb-0.1.4 gem fails during the build phase when installed using gem install curb.
- I used libcurl-7.15.1 for the underlying curl implementation.
- So I obtained the original gem, hacked it around a bit and made my own revised version: curb-0.1.4.gem.
- I also had to hack the Ruby config.h file to remove the following compiler version check (my compiler is a more recent version):
#if _MSC_VER != 1200 #error MSC version unmatch #endif - To install the gem, do the following:
- Unzip libcurl-7.15.1 into a directory LIBCURL_DIR
- Install the gem as follows:
gem install curb-0.1.4.gem -- --build-flags --with-curllib=libcurl_imp --with-curl-lib=%LIBCURL_DIR% --with-curl-include=%LIBCURL_DIR%\include
- Make sure libcurl.dll is on the system path or somewhere where it is accessible by the Ruby development web server
- And it should just work. Right? Well, actually, since I'm using a later version of the MSVC compiler, I need to do a bit more hacking. Specifically, the build of curb produces the gem binary curb_core.so which is really just a DLL and it happens to reference version 9.0 of the Microsoft C Runtime which does not jive well with Ruby which was built using, you guessed it, version 12.0 of the compiler. The solution is to rebuild curb_core.so with static linking against the C runtime library:
- Find your copy of curb_core.so in your Ruby gems directory. There'll most likely be two copies: one under gems\1.8\gems\curb-0.1.4\ext\curb_core.so and another under gems\1.8\gems\curb-0.1.4\lib\curb_core.so.
- In the ext directory, open Makefile search for -MD and change it to -MT (static linking instead of dynamic).
- Rebuild under ext by running nmake.
- Copy the rebuilt curb_core.so under the lib directory.
- That should be it.
Good luck!
Attached resources:
Posted: Friday 13 February 2009 10:04 p.m. by rcook (315 words) Edit | Delete