Togl widget, where to install it?

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 nametogl’
Exception RuntimeError' at /usr/lib/ruby/1.6/tk.rb:889 - invalid command name "togl" ExceptionNameError’ at /usr/lib/ruby/1.6/tk.rb:604 - invalid command name togl' /usr/lib/ruby/1.6/tk.rb:604:intk_call’: invalid command name togl' (NameError) from /home/bard/lib/ruby/togl.rb:54:increate_self’
from /usr/lib/ruby/1.6/tk.rb:2229:in initialize' from test.rb:3:innew’
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.

Hi,

···

From: Massimiliano Mirra - bard mmirra@libero.REMOVETHIS.it
Subject: Togl widget, where to install it?
Date: Thu, 17 Jul 2003 08:11:54 +0900
Message-ID: 87oezu8460.fsf@prism.localnet

[“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.

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.

I don’t use the library.

So, I don’t check whether the library works or not.


Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

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

Hi,

···

From: Massimiliano Mirra - bard mmirra@libero.REMOVETHIS.it
Subject: Re: Togl widget, where to install it?
Date: Thu, 17 Jul 2003 17:54:19 +0900
Message-ID: 87oezt7dba.fsf@prism.localnet

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

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).
(2) call “load ./togl.so” by using Tk.tk_call(‘load’, ‘./togl.so’).
After doing one of them, please try TkPackage.require(‘Togl’)

                              Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

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!

Hi,

···

From: Massimiliano Mirra - bard mmirra@libero.REMOVETHIS.it
Subject: Re: Togl widget, where to install it?
Date: Fri, 18 Jul 2003 07:20:53 +0900
Message-ID: 87k7agyi5o.fsf@prism.localnet

I didn’t know about TkPackage.add_path, thanks, that did the trick!

FYI, you can access the auto_path list by Tk:AUTO_PATH.
It is a TkVariable object. For example,

[ruby]$ /usr/local/bin/irb -r tk
irb(main):001:0> Tk::AUTO_PATH
=> #<TkVariable: auto_path>
irb(main):002:0> Tk::AUTO_PATH.value
=> “/usr/lib/tcl8.0jp /usr/lib /usr/lib/tk8.0jp”
irb(main):003:0> Tk::AUTO_PATH.to_a
=> [“/usr/lib/tcl8.0jp”, “/usr/lib”, “/usr/lib/tk8.0jp”]
irb(main):004:0> Tk::AUTO_PATH.value = Tk::AUTO_PATH.to_a << ‘/usr/local/lib’
=> [“/usr/lib/tcl8.0jp”, “/usr/lib”, “/usr/lib/tk8.0jp”, “/usr/local/lib”]
irb(main):005:0> Tk::AUTO_PATH.to_a
=> [“/usr/lib/tcl8.0jp”, “/usr/lib”, “/usr/lib/tk8.0jp”, “/usr/local/lib”]


Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)