Problem installing Ruby/Tk

Installed Linux
Ruby 1.8.5 from source

I dont’t know if I have Tcl/Tk installed already, but I found this
folder:
/home/christopherl/ruby-1.8.5/ext/tk
/home/christopherl/ruby-1.8.5/lib/test/unit/ui/tk

I have also Ruby in these folders:
/usr/lib/ruby
/usr/local/lib/ruby

I tried to run this program
require ‘tk’

hello = TkRoot.new {title “Hello World”}
Tk.mainloop

But got this when I tried to run the program:
test.rb:1:in `require’: no such file to load – Tk (LoadError)
from test.rb:1

Suggestions?

Installed Linux
Ruby 1.8.5 from source
I dont’t know if I have Tcl/Tk installed already, but I found this
folder:
/home/christopherl/ruby-1.8.5/ext/tk
/home/christopherl/ruby-1.8.5/lib/test/unit/ui/tk

Yes that’s the source for the tk extensions
Ruby needs that to be compiled

I have also Ruby in these folders:
/usr/lib/ruby
/usr/local/lib/ruby

good

But got this when I tried to run the program:
test.rb:1:in `require’: no such file to load – Tk (LoadError)
from test.rb:1
Suggestions?

It looks like the build process wasn’t able to find Tcl/Tk headers, so
your compiled Ruby ended up without compiled tk extensions.

Can you check whether you have Tk installed in your system, and in
case the answer is positive, verify it provides the necessary header
files.

If the package you use for Tk provides the headers, it may be storing
them in a find the build process is not able to find without
assistance, so you would have to let the ruby build process know that.

Hope that helps

best,
UG

Uma G.

Can you check whether you have Tk installed in your system, and in
case the answer is positive, verify it provides the necessary header
files.

If the package you use for Tk provides the headers, it may be storing
them in a find the build process is not able to find without
assistance, so you would have to let the ruby build process know that.

How can I determine if I have Tk installed?
I have a Tk.rb in the folder /home/christopherl/ruby-1.8.5/ext/tk/lib.

Here are some folders I have:
home/christopherl/ruby-1.8.5/ext/tk
/home/christopherl/ruby-1.8.5/ext/tk/lib
/home/christopherl/ruby-1.8.5/ext/tk/lib/tk
/home/christopherl/ruby-1.8.5/ext/tk/lib/tkextlib
/home/christopherl/ruby-1.8.5/ext/tk/sample
/home/christopherl/ruby-1.8.5/ext/tk/tkutil

I’ve installed ActiveTcl8.4, in /usr/local/ActiveTcl-8.4.

I tried to require ‘tk’ but same problem.
Ruby don’t find right path or something??

I’ve read this text, same problem as me, but I don’t understand, do you?
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/35014

How can I determine if I have Tk installed?
I have a Tk.rb in the folder /home/christopherl/ruby-1.8.5/ext/tk/lib.
Here are some folders I have:
home/christopherl/ruby-1.8.5/ext/tk
/home/christopherl/ruby-1.8.5/ext/tk/lib
/home/christopherl/ruby-1.8.5/ext/tk/lib/tk
/home/christopherl/ruby-1.8.5/ext/tk/lib/tkextlib
/home/christopherl/ruby-1.8.5/ext/tk/sample
/home/christopherl/ruby-1.8.5/ext/tk/tkutil

That’s actually not Tk, but Ruby’s Tk binding for Tk, which needs the
actual Tk library in order to be compiled.

Tk usually comes together with Tcl, a scripting language that was the
first to bundle Tk, so a good way to find out whether you have the
Tcl/Tk pair at all is:
which tclsh

In my openSuse 10.1 box I found libtk to be at:
/usr/lib/libtk8.4.so

but that alone is not enough, you also need to have the C header
files, most probably somewhere inside /usr/include

this is so the ruby build process can build the Tk extension binary
linked against the shared library, so both the Tk header (.h) and the
binary (.so) are needed.

If you find out you don’t have Tk installed, or only one of the needed
pieces, you will need to install the part you’re missing.

If you use Debian or a Debian based distro like
Ubuntu: Debian -- Error
so you can:
apt-get install tk8.4
apt-get install tk8.4-dev

I think Redhat, Suse and Fedora come with Tk by default, but if you
are missing them for some reason, you can install what you need using
Yast, Yum, or apt for RPM.

Of course, the remaining option is building and installing Tcl/tk from
source, just as you’re doing with Ruby. Source available at:
http://www.tcl.tk (neat TLD by the way)

Hope that helps,

                            UG

Uma G.

Does ActiveTcl come with development headers and files? Did you install
ActiveTcl before or after Ruby? Did the ./configure for Ruby say if and
where it found Tcl? Did you try to reconfigure Ruby manually pointing
./configure at the relevant Tcl/Tk directories and reinstall? Why aren’t
you using prebuilt binaries anyway?

I’ve installed ActiveTcl after Ruby.
where do I run ./configure?
what is prebuilt binaries? isn’t that?

Christopher L. wrote:

I’ve installed ActiveTcl8.4, in /usr/local/ActiveTcl-8.4.

I tried to require ‘tk’ but same problem.
Ruby don’t find right path or something??

I’ve read this text, same problem as me, but I don’t understand, do you?
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/35014

Does ActiveTcl come with development headers and files? Did you install
ActiveTcl before or after Ruby? Did the ./configure for Ruby say if and
where it found Tcl? Did you try to reconfigure Ruby manually pointing
./configure at the relevant Tcl/Tk directories and reinstall? Why aren’t
you using prebuilt binaries anyway?

David V.

I’ve installed ActiveTcl8.4, in /usr/local/ActiveTcl-8.4.
I tried to require ‘tk’ but same problem.
Ruby don’t find right path or something??

no, when you require “tk”, what you’re doing is to load the ruby
binding for tk
not Tk itself. In turn the ruby binding will load
libtk.so.
In order to build the ruby binding when you compile ruby (or
afterwards, using the same build process) you need:

  1. Tk shared binary object ( /usr/lib/libtk*.so
  2. Tk C headers somewhere in /usr/include

I have no idea what is Active Tcl like, never used that particular
product, but I’m sure the guidelines I gave you should at least give
us an idea of what’s the problem.
If Active Tcl is similar to other products like Active Perl, then it
doesn’t come with the necessary header files.

did you try any of the tests I suggested in the previous mail ?

I’ve read this text, same problem as me, but I don’t understand, do you?
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/35014

finding a new problem won’t solve yours, it’s as easy as following
these minimal checks

best,

Christopher L. wrote:

/ …

I’ve installed ActiveTcl after Ruby.
where do I run ./configure?

In the root directory of the source. Where an executable script file
named
“configure” is located.

what is prebuilt binaries? isn’t that?

“Prebuilt binaries” are executable binaries pre-compiled and ready to to
run
on a particular operating system version.

The earlier poster’s point is that using prebuilt binaries avoids the
problems you are having right now, assuming they are available for your
operating system version.

I found the C headers Tk.h and tcl.h in:
/usr/local/ActiveTcl-8.4/include

and libtk.so in:
usr/local/ActiveTcl-8.4/lib

how do I now put it all toghether?
why ran congfigure shell script a couple of times, suddenly the script
is
gone??

thanks for your support.

Christopher L. wrote:

I found the C headers Tk.h and tcl.h in:
/usr/local/ActiveTcl-8.4/include

and libtk.so in:
usr/local/ActiveTcl-8.4/lib

how do I now put it all toghether?
why ran congfigure shell script a couple of times, suddenly the script
is
gone??

If “suddenly the script is gone”, without any further information about
what
actions you may have taken, or details of your setup, it’s really not
possible to offer assistance.

If you want use the ActiveTcl libraries, please try

$ ./configure --with-tcl-dir=/usr/local/ActiveTcl-8.4/
–with-tk-dir=/usr/local/ActiveTcl-8.4/ --with-tcllib=tclstub8.4
–with-tklib=tkstub8.4 --enable-tcltk-stubs

or

$ ./configure --with-tcl-dir=/usr/local/ActiveTcl-8.4/
–with-tk-dir=/usr/local/ActiveTcl-8.4/ --with-tcllib=tclstub8.4
–with-tklib=tkstub8.4 --enable-tcltk-stubs --enable-pthread

, and recompile and reinstall.

Necessity of “–enable-pthread” depends on your ActiveTcl’s version.

I ran these configure codes, but what you mean by recompile and
reinstall?

From: Christopher L. [email protected]
Subject: Problem installing Ruby/Tk
Date: Mon, 18 Dec 2006 22:03:27 +0900
Message-ID: [email protected]

Installed Linux
Ruby 1.8.5 from source
(snip)
But got this when I tried to run the program:
test.rb:1:in `require’: no such file to load – Tk (LoadError)
from test.rb:1

If you fail “require ‘tcltklib’”,
you have no available tcltklib.so on your Ruby’s library path.
Probably, “configure” command couldn’t find Tcl/Tk libraries.

From: Christopher L. [email protected]
Subject: Re: Problem installing Ruby/Tk
Date: Tue, 19 Dec 2006 01:50:13 +0900
Message-ID: [email protected]

I’ve installed ActiveTcl8.4, in /usr/local/ActiveTcl-8.4.

If you want use the ActiveTcl libraries, please try

$ ./configure --with-tcl-dir=/usr/local/ActiveTcl-8.4/
–with-tk-dir=/usr/local/ActiveTcl-8.4/ --with-tcllib=tclstub8.4
–with-tklib=tkstub8.4 --enable-tcltk-stubs

or

$ ./configure --with-tcl-dir=/usr/local/ActiveTcl-8.4/
–with-tk-dir=/usr/local/ActiveTcl-8.4/ --with-tcllib=tclstub8.4
–with-tklib=tkstub8.4 --enable-tcltk-stubs --enable-pthread

, and recompile and reinstall.

Necessity of “–enable-pthread” depends on your ActiveTcl’s version.

Christopher L. wrote:

–with-tklib=tkstub8.4 --enable-tcltk-stubs --enable-pthread

, and recompile and reinstall.

Necessity of “–enable-pthread” depends on your ActiveTcl’s version.

I ran these configure codes, but what you mean by recompile and
reinstall?

make; make install

You might need

make clean

before, see if it works without.

Vince