Monday, March 23, 2009

Build QtRuby with Ruby 1.9.1 and Qt 4.5 #3

(continued from phosphorescence: Build QtRuby with Ruby 1.9.1 and Qt 4.5 #2)

LoadError occurs when required libraries (shared libraries or gems, etc.) are not found. Default libraries are that of ruby 1.8.7 and of Qt 4.4; these are on the load path. But my target libraries are not.

I should set load path, by using $LD_LIBRARY_PATH. Ruby 1.9.1's library path is /opt/ruby-1.9.1/lib and Qt 4.5's library path is /opt/qtsdk-2009.01/qt/lib. Setting in bash is below:
if [ -d '/opt/ruby-1.9.1/lib' ] ; then
  export LD_LIBRARY_PATH='/opt/ruby-1.9.1/lib':$LD_LIBRARY_PATH
if [ -d '/opt/qtsdk-2009.01/qt/lib' ] ; then
  export LD_LIBRARY_PATH='/opt/qtsdk-2009.01/qt/lib':$LD_LIBRARY_PATH

For KDE user, above shell script can't set /etc/bashrc, /etc/profile, .bashrc, .profile, and so on. Because default KDE is built with default Qt, and KDE will be confused if non-default Qt is loaded. So above shell script should be hand-operated.

Then check $LD_LIBRARY_PATH.

Retry irb.
irb(main):001:0> require 'Qt'
=> true

Let's check executable files of QtRuby.
>/opt/ruby-1.9.1/bin/rbrcc -version
Ruby Resource Compiler for Qt version 4.5.0
>/opt/ruby-1.9.1/bin/rbuic4 -v
Qt User Interface Compiler version 4.5.0
>/opt/ruby-1.9.1/bin/rbqtapi -v
/usr/lib64/ruby/site_ruby/1.8/x86_64-linux/ /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/ undefined symbol: classname - /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/ (LoadError)
from /usr/lib64/ruby/site_ruby/1.8/Qt4.rb:5
from /opt/ruby-1.9.1/bin/rbqtapi:6:in `require'
from /opt/ruby-1.9.1/bin/rbqtapi:6

What happen in rbqtapi. show this file until line 6.
#!/usr/bin/env ruby

# Note: this program is part of qtruby and makes use of its internal functions.
# You should not rely on those in your own programs.

require 'Qt4'

Line 1, shebang indicates ruby on the $PATH. Normally, ruby 1.9.1 executable should be added to $PATH, but I planned to rewrite shebang locally.

Retry rbqtapi.
>/opt/ruby-1.9.1/bin/rbqtapi -v
QtRuby 2.0.2 using Qt-4.5.0

Finally, Build succeeds!

No comments:

Post a Comment