Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

How to compile Ruby from source on Windows for FS3

For general discussion related FlowStone

How to compile Ruby from source on Windows for FS3

Postby digitalwhitebyte » 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?

  1. After downloaded unzip it locally to say c:\ruby-src
  2. 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,
  3. run vcvars32.bat, you can locate it in your MSV folder like <MSV path>\VC\bin
  4. Make a folder for your build say c:\ruby-build. Move into it / change dir

  1. c:\ruby-build> c:\ruby-1.9.3-p0\win32\configure.bat
  2. c:\ruby-build> nmake
  3. c:\ruby-build> nmake test
  4. 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.
:mrgreen:

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.
Last edited by digitalwhitebyte on Sat Jul 13, 2013 7:45 am, edited 6 times in total.
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: How to compile Ruby from source on Windows for FS3

Postby digitalwhitebyte » Mon Nov 26, 2012 11:48 am

I managed to create a full version which also supports yaml and zlib,
so to have the ability to install gems (when package is ready, I try to put it online for download).
so now some tests:
installed the gem FFI, works really well,
but here FS3 after a while I get the message that you can see, (please click on image an wait) :shock:
now I wonder in the future it will be possible to disable this protection?
Otherwise, any process that is not executed within the time set will be judged to be locked,
but in reality the example is just waiting for you to press the ok button.

Malc there are tricks to be taken?

I hope this will work without ruby goes off.

Test with FFI on FlowStone 3.gif
Test with FFI on FlowStone 3.gif (626.87 KiB) Viewed 29918 times
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: How to compile Ruby from source on Windows for FS3

Postby rlr » Tue Nov 27, 2012 12:07 am

Interesting experiment!
So if I understand right you're loading your own ruby dll instead of the msvcr90-ruby191.dll into flowstone?
Did you test what gets loaded if you run an exported exe or VST dll?
(An exported exe or dll has the ruby runtime included)

cheers for the hacking efforts!
rlr
 
Posts: 27
Joined: Tue Jul 13, 2010 9:17 pm

Re: How to compile Ruby from source on Windows for FS3

Postby digitalwhitebyte » Tue Nov 27, 2012 12:45 am

No Hacking, but Implementation.
The ruby ​​interpreter used by Malc was compiled on windows platform compiler with Visual Studio 2008 I think,
so it is linking to msvcr90.dll runtime, this indicates it in the name of the library msvcr90-ruby191.dll.
So knowing this, I have compiled from Ruby binary for this runtime version,
and compiled the various libraries are essential to be able to install gems, yaml and zlib.
At this point I have a compiled version of Ruby, which is not based on mingw compiler, but on visual studio.
Now being based on the same runtime dependency, what will you implement in your compiled version of ruby,
gems, or otherwise, or existing libraries, can be used by the existing version of msvcr90-ruby191.dll in FS3,
without changing the DLL, but simply integrate libraries or gems, with commands

$ LOAD_PATH "My_Path / my_folder /" # pointing to it
require "my_lib" # include it.

making sure you give then to your exe or vst, the folder with the proper libraries added.

I managed to successfully implement a lot of things, but as the post above,
you should see if we can eliminate the auto-off of ruby code, otherwise some things will not be implemented.
I think the beauty of having ruby in FS3 is precisely this type of use.
Malc will tell us something soon as he can.
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: How to compile Ruby from source on Windows for FS3

Postby trogluddite » Tue Nov 27, 2012 1:18 am

Nice work, DWB. :)
I need to learn much more Ruby before confusing myself with extra lib's - but it is very good to know that we can go beyond the things included with the FS installer. Made a bookmark in my browser because I KNOW I will want to return to this later when I know Ruby better.
Maybe the solution for the 'protection' is to have a simple switch; like the standard Ruby $DEBUG constant. We could have maybe "$FS_PROTECT=true" by default at startup but able to set to false by the user in the code. The protection is surely useful (like red links for 'green') - but would be a shame if it prevented full use of external Ruby lib's and dll's.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: How to compile Ruby from source on Windows for FS3

Postby digitalwhitebyte » Wed Nov 28, 2012 4:45 pm

Support?
Before embarking on the adventure I want to know if this will be possible.
It would be also nice to know what's in the pipeline.
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: How to compile Ruby from source on Windows for FS3

Postby digitalwhitebyte » Fri Nov 30, 2012 8:25 am

:idea: :?:
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: How to compile Ruby from source on Windows for FS3

Postby Tronic » Mon Dec 03, 2012 6:06 am

I also am interested to know if this is possible.
Support a few words about this?
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: How to compile Ruby from source on Windows for FS3

Postby support » Mon Dec 03, 2012 10:00 am

Sorry - must have missed this. Please do feel free to email us if you need a response or you think we've missed something. Use our support address at the top of this page.

There's quite alot to digest here. After a quick scan I'd say that what you're doing is indeed correct - well, it obviously works so that's as good a test as any! :)

Regarding the protection, you're right there are situations where you could be waiting for the Ruby thread to return but not be in an unrecoverable situation. We don't currently have a way to get round this but I can see it would be useful if we did. We will need to have a look into it.

Nice work btw.
User avatar
support
 
Posts: 151
Joined: Fri Sep 07, 2012 2:10 pm

Re: How to compile Ruby from source on Windows for FS3

Postby digitalwhitebyte » Fri Dec 07, 2012 8:04 am

Thanks Malc for your attention.
I am confident that this happens to give real power to Ruby. :twisted:
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Next

Return to General

Who is online

Users browsing this forum: No registered users and 72 guests