How I built libyaml on Windows with MSVC++

Mar 17, 2012 21:57

So, my foray into building libyaml on Windows. I don't know if this is the right solution, but it worked for me. Anyway, back to the story.

The rubygems library, or at least the gem command line tool, requires a yaml parser to be installed in order to work properly. That means either Syck or Psych. In Ruby 1.9 it wants Pysch.

If you're using the Ruby Installer this is no big deal. It's already built for you and the gem command just works. If you want to build it using the Microsoft toolchain, things get a little trickier.

First, grab and unzip + untar libyaml. In Visual Studio, which I'm assuming you have installed, go to File -> Open -> Project/Solution and selection libyaml-x.y.z\win32\vs2008\libyaml.sln (or just libyaml if it doesn't show file extensions). From there you'll need to build the yamldll project. Ignore the rest, just right click on that one and select "build solution". If all goes well, you should have a .lib and .dll file under libyaml-x.y.z\win32\vs2008\Output\Debug\lib\DLL.

Then, copy the yaml.lib and yaml.dll files in your favorite location under the 'lib' directory. I put mine in c:\usr\yaml\lib. Then copy the yaml.h file (found under libyaml-x.y.z\include) in the same location, but in an 'include' directory. I put mine in c:\usr\yaml\include. I also had to copy the yaml.dll file to the same directory as the Ruby executable to get things to work, but I'm not sure why.

From there you should be able to build Psych. Go to wherever you unpacked the Ruby source, and cd to ext/psych. Then run "ruby extconf.rb --with-libyaml-dir=c:\usr\yaml; nmake; nmake install."

After I installed zlib (using pr-zlib instead), gem install worked just fine. :)

ruby, yaml

Previous post Next post
Up