Hello to the whole community. Today I will write how to set up qt and ruby bindings in Linux and Windows.
Ruby is an interpreted high-level language for fast and easy object-oriented programming. The language has a multithreading implementation independent of the operating system, strict dynamic typing, a garbage collector and many other features. Ruby is similar in syntax to Pearl and Eiffel, in object-oriented approach to Smalltalk. Also some features of the language are taken from Python, Lisp, Dylan and CLU.
More hereTrolltech
Qt (pronounced “quit”) is a cross-platform software development toolkit in the C ++ programming language.
More hereLinux
The Linux system I will have is Ubuntu, since I work on it. I think the rest will not be difficult either. Let's start with it. Go to System-> Administration-> Synaptic Package Manager. We need to deliver the minimum packages:
-
ruby-full - complete installation of ruby
-
rubygems - gems for ruby
-
libgemplugin-ruby - plugin for ruby
-
libqt4-ruby - ruby library for working with qt
The system will pull up the rest of the dependencies (for example, libqt4-core, libqt4-gui, etc.)
We also need an editor for working with Ruby. I use SciTE. It's a matter of taste :)
After the packages are installed, we can test the performance. Go to the
tutorial , and take for example
3 example .
')
require 'Qt4'
app = Qt :: Application.new (ARGV)
window = Qt :: Widget.new ()
window.resize (200, 120)
quit = Qt :: PushButton.new ('Quit', window)
quit.font = Qt :: Font.new ('Times', 18, Qt :: Font :: Bold)
quit.setGeometry (10, 40, 180, 40)
Qt :: Object.connect (quit, SIGNAL ('clicked ()'), app, SLOT ('quit ()'))
window.show ()
app.exec ()
I will not describe what this code does - there everything is explained in detail below in the same manual. A form should appear with an exit button. The code in SciTE is saved under the rb extension and press F5 (default parameters should work fine).
Our result

And here is the long-awaited window

If it appears, then everything is installed successfully and you can start programming. I will add that mainly with the installation and configuration for Linux there should not be any special problems, because I put it on dozens of machines and have not seen any problems with it yet.
Windows
Now we’ll start with
Windows (get more out of it).
We will need:
-
Ruby 1.8.5 Installer in one click - the name speaks for itself :)
-
qtruby4-1.4.9-mswin32.gem - qt4 library for ruby
-
nmake - the automatic build utility for Windows (without it, qtruby will not be installed)
To begin with, install Ruby (during installation, rubygems will also be installed).
SciTe will also be in the installation :)

Next we need to run nmake. It will create two files - NMAKE.ERR and NMAKE.EXE. What would the rubygems do not search for it for a long time? Copy them into% RUBY_DIR% \ bin, where% RUBY_DIR% is the directory where you installed Ruby.
Then go to the command line (Start-> Run-> cmd). Check that the gem is registered in the system and works - we write gem --help. If I wrote help, everything is fine.

Now install qtruby. Go to the directory (in the console) where we downloaded qtruby4-1.4.9-mswin32.gem and write the command gem install qtruby4-1.4.9-mswin32.gem. The installation should complete successfully.

If you wrote "buffer error", then you downloaded qtruby, which is not suitable for your system.
At first I thought it was all, but it was not there. It took another library -
mingwm10.dll .

I downloaded it
here and dropped it in% RUBY_DIR% \ bin.
Well, now we can launch our application and admire the window with the button.
Good luck to you programming!