How to compile Ruby from source on Windows for FS3
Posted: Fri Nov 23, 2012 3:43 pm
I start by saying that this mini-guide is aimed at people
who want to expand and experiment with the possibilities of the FS3 in Ruby,
or create custom ruby extensions for FS3.
If you do not already have the compiler can be installed MVStudio 2008 or MVC++ 2008.
Express editions just fine, too.
Do not use other versions because,
i think, FS3 has the ruby interpreter compiled with these versions
i386-mswin32_90 that is linked to the runtime libraries msvcr90.dll.
Get the source zip from the download page,
i have used this version ruby-1.9.3-p0.zip, for me work,
but support can link at better version or is the one?
That's it.. you'll find the binaries within a usr folder within the ruby-build folder.
in this way you can use the other standard libraries or add ruby gems,
and have the basics for creating personal extensions.
To use them, then you can simply link them like
$ LOAD_PATH << "C:/ruby-build/usr/lib/ruby/1.9.1"
$ LOAD_PATH << "C:/ruby-build/usr/lib/ruby/1.9.1/i386-mswin32_90"
or by including them in FS3 folder
C:\Program Files (x86)\DSPRobotics\Flowstone\ruby\libraries\win32\common
C:\Program Files (x86)\DSPRobotics\Flowstone\ruby\libraries\win32\i386
I prefer the external folders, so you do not have problems with future FS3 updates.
But remember to attach and also link them to your exe or vst.

UPDATE:
To have the functionality of rubygem installation, follow this instruction:
How I built libyaml on Windows with MSVC++
(article from http://djberg96.livejournal.com/180132.html)
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 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.
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. (or see new update)
Then each time you want to install a rubygem,
remember to always load before the environment variables from file vcvars32.bat
If ruby is not recognized as internal command windows, verify that you have the environmet variable that points to ruby,
in the environment varibile system there must be in the variable
PATH, in addition to others that are already there (be careful not to delete existing ones)
you have to add
for example in my case:
other .... existent path; C:\usr\bin
(use ; semicolon character as separator)
UPDATE:
New solution to install zlib. thank to Dimmak01
Download zlib-1.2.5.win32.zip
put all files in x:Ruby_source/ext/zlib
cd x:Ruby_source/ext/zlib
ruby extconf.rb; nmake; nmake install
---------------------------------------------
Happy build, to anyone.
who want to expand and experiment with the possibilities of the FS3 in Ruby,
or create custom ruby extensions for FS3.
If you do not already have the compiler can be installed MVStudio 2008 or MVC++ 2008.
Express editions just fine, too.
Do not use other versions because,
i think, FS3 has the ruby interpreter compiled with these versions
i386-mswin32_90 that is linked to the runtime libraries msvcr90.dll.
Get the source zip from the download page,
i have used this version ruby-1.9.3-p0.zip, for me work,
but support can link at better version or is the one?
- After downloaded unzip it locally to say c:\ruby-src
- Open the Visual Studio/C++ Command prompt (I have MSV C++2008 on W7 SP1),
or run CMD prompt, but make sure you run it as administrator, - run vcvars32.bat, you can locate it in your MSV folder like <MSV path>\VC\bin
- Make a folder for your build say c:\ruby-build. Move into it / change dir
- c:\ruby-build> c:\ruby-1.9.3-p0\win32\configure.bat
- c:\ruby-build> nmake
- c:\ruby-build> nmake test
- c:\ruby-build> nmake DESTDIR=c:/ruby-build install
That's it.. you'll find the binaries within a usr folder within the ruby-build folder.
in this way you can use the other standard libraries or add ruby gems,
and have the basics for creating personal extensions.
To use them, then you can simply link them like
$ LOAD_PATH << "C:/ruby-build/usr/lib/ruby/1.9.1"
$ LOAD_PATH << "C:/ruby-build/usr/lib/ruby/1.9.1/i386-mswin32_90"
or by including them in FS3 folder
C:\Program Files (x86)\DSPRobotics\Flowstone\ruby\libraries\win32\common
C:\Program Files (x86)\DSPRobotics\Flowstone\ruby\libraries\win32\i386
I prefer the external folders, so you do not have problems with future FS3 updates.
But remember to attach and also link them to your exe or vst.
UPDATE:
To have the functionality of rubygem installation, follow this instruction:
How I built libyaml on Windows with MSVC++
(article from http://djberg96.livejournal.com/180132.html)
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 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.
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. (or see new update)
Then each time you want to install a rubygem,
remember to always load before the environment variables from file vcvars32.bat
If ruby is not recognized as internal command windows, verify that you have the environmet variable that points to ruby,
in the environment varibile system there must be in the variable
PATH, in addition to others that are already there (be careful not to delete existing ones)
you have to add
for example in my case:
other .... existent path; C:\usr\bin
(use ; semicolon character as separator)
UPDATE:
New solution to install zlib. thank to Dimmak01
Download zlib-1.2.5.win32.zip
put all files in x:Ruby_source/ext/zlib
cd x:Ruby_source/ext/zlib
ruby extconf.rb; nmake; nmake install
---------------------------------------------
Happy build, to anyone.