I downloaded and built the ToGL tk widget for OpenGL from togl.sf.net.
Samples run fine (well, most of them).
I downloaded and built rbogl-0.32b.tgz (OpenGL bindings for Ruby). I
put opengl.so and glut.so in RUBYLIB. Samples run fine.
I downloaded the ToGL bridge for ruby from
http://mirrors.sunsite.dk/ruby/contrib/togl.tar.gz. I put the togl.rb
file in RUBYLIB. This is what I get when I try to run test.rb or any
other sample:
bard@prism:~/workspace/ruby/tk$ ruby -d test.rb
test.rb:10: warning: Clear (…) interpreted as method call
/usr/lib/ruby/1.6/complex.rb:335: warning: discarding old **
/usr/lib/ruby/1.6/mathn.rb:16: warning: discarding old gcd2
/usr/lib/ruby/1.6/mathn.rb:117: warning: discarding old inspect
/usr/lib/ruby/1.6/mathn.rb:225: warning: discarding old sqrt
tcltklib: Tcl_FindExecutable
tcltklib: Tcl_CreateInterp
tcltklib: Tcl_Init
tcltklib: Tk_Init
tcltklib: Tcl_StaticPackage(“Tk”)
tcltklib: Tcl_CreateObjCommand(“ruby”)
tcltklib: Tcl_Eval(array get tcl_platform)
tcltklib: (TCL_Eval result) 0
[“encoding”, “system”]
=> “encoding system”
/usr/lib/ruby/1.6/tk.rb:887: warning: instance variable @encoding not initialized
==> “iso8859-1"
tcltklib: Tcl_Eval(global auto_path; set auto_path “/usr/lib/tcl8.3 /usr/lib /usr/lib/tk8.3”)
tcltklib: (TCL_Eval result) 0
"create_self has no arg”
[“togl”, “.w0000”]
=> "togl .w0000"
Exception NameError' at /usr/lib/ruby/1.6/tk.rb:889 - invalid command name
togl’
Exception RuntimeError' at /usr/lib/ruby/1.6/tk.rb:889 - invalid command name "togl" Exception
NameError’ at /usr/lib/ruby/1.6/tk.rb:604 - invalid command name togl' /usr/lib/ruby/1.6/tk.rb:604:in
tk_call’: invalid command name togl' (NameError) from /home/bard/lib/ruby/togl.rb:54:in
create_self’
from /usr/lib/ruby/1.6/tk.rb:2229:in initialize' from test.rb:3:in
new’
from test.rb:3
tcltklib: Tcl_DeleteInterp
Where should the togl.so be put in order for ruby/tk to be able to
access it? I tried the directories mentioned in the debug output
(/usr/lib/tcl8.3 /usr/lib /usr/lib/tk8.3) with no result.
Hidetoshi NAGAI nagai@ai.kyutech.ac.jp writes:
Probably, ToGL library is not loaded to Tk interpreter.
ToGL bridge for ruby requires to link the ToGL library to
tcltklib (written on the ‘README.euc’ file). If the library
cannot create as a loadable module, ‘link to tcltklib’ is the
only way to use it on Ruby/Tk. But if your Tcl/Tk can load the
library by ‘package’ command, you can use TkPackage module to
load the library to Ruby/Tk. Please use TkPackage.require to
load the library. If succeed, the library will be loaded and
’togl’ command will be defined on the Tk interpreter. After that,
togl.rb will work fine.
Almost there.
bard@prism:~/workspace/ruby/Togl-1.6$ tclsh
% package require Togl
can't find package Togl
% load togl.so
couldn't load file "togl.so": togl.so: cannot open shared object
file: No such file or directory
% load ./togl.so
% package require Togl
1.6
This means that it is built as a loadable module. I then copied
togl.so over to /usr/lib and ran:
bard@prism:~/workspace/ruby/Togl-1.6$ irb
irb(main):001:0> require 'tk’
true
irb(main):002:0> TkPackage.require(‘togl’)
RuntimeError: can’t find package togl
from /usr/lib/ruby/1.6/tk.rb:889:in _invoke' from /usr/lib/ruby/1.6/tk.rb:889:in
_invoke’
from /usr/lib/ruby/1.6/tk.rb:596:in tk_call' from /usr/lib/ruby/1.6/tk.rb:642:in
require’
from (irb):2
irb(main):003:0> TkPackage.require(‘Togl’)
RuntimeError: can’t find package Togl
from /usr/lib/ruby/1.6/tk.rb:889:in _invoke' from /usr/lib/ruby/1.6/tk.rb:889:in
_invoke’
from /usr/lib/ruby/1.6/tk.rb:596:in tk_call' from /usr/lib/ruby/1.6/tk.rb:642:in
require’
from (irb):3
irb(main):004:0> require 'togl’
true
irb(main):005:0> TkPackage.require(‘togl’)
RuntimeError: can’t find package togl
from /usr/lib/ruby/1.6/tk.rb:889:in _invoke' from /usr/lib/ruby/1.6/tk.rb:889:in
_invoke’
from /usr/lib/ruby/1.6/tk.rb:596:in tk_call' from /usr/lib/ruby/1.6/tk.rb:642:in
require’
from (irb):5
irb(main):006:0> TkPackage.require(‘Togl’)
RuntimeError: can’t find package Togl
from /usr/lib/ruby/1.6/tk.rb:889:in _invoke' from /usr/lib/ruby/1.6/tk.rb:889:in
_invoke’
from /usr/lib/ruby/1.6/tk.rb:596:in tk_call' from /usr/lib/ruby/1.6/tk.rb:642:in
require’
from (irb):6
Can you please tell me where togl.so should be put for
TkPackage.require to find it? Unfortunately README.euc is of no help
since I cannot read Japanese and I have no experience with Tcl/Tk.
Thank you.
Massimiliano
Hidetoshi NAGAI nagai@ai.kyutech.ac.jp writes:
Well, your togl.so library is not on Tcl/Tk’s auto_path, is it?
Probably, there are two ways for loading togl.so to Ruby/Tk.
(1) put togl.so on the auto_path.
or add the new path for togl.so to the auto_path
by TkPackage.add_path(new_path).
I didn’t know about TkPackage.add_path, thanks, that did the trick!