Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem installing Ruby/Tk

281 views
Skip to first unread message

Christopher Latif

unread,
Dec 18, 2006, 8:03:27 AM12/18/06
to
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?

--
Posted via http://www.ruby-forum.com/.

Uma Geller

unread,
Dec 18, 2006, 9:22:28 AM12/18/06
to
> 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 Geller
http://umageller.wordpress.com

Christopher Latif

unread,
Dec 18, 2006, 10:40:15 AM12/18/06
to
> 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

Uma Geller

unread,
Dec 18, 2006, 11:28:15 AM12/18/06
to
> 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: http://packages.debian.org/unstable/libs/tk8.4
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,

Christopher Latif

unread,
Dec 18, 2006, 11:50:13 AM12/18/06
to
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

David Vallner

unread,
Dec 18, 2006, 12:53:26 PM12/18/06
to
Christopher Latif 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 Vallner

signature.asc

Christopher Latif

unread,
Dec 18, 2006, 1:10:01 PM12/18/06
to
> 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?

Paul Lutus

unread,
Dec 18, 2006, 1:29:27 PM12/18/06
to
Christopher Latif 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.

--
Paul Lutus
http://www.arachnoid.com

Uma Geller

unread,
Dec 18, 2006, 1:58:07 PM12/18/06
to
> 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,

Hidetoshi NAGAI

unread,
Dec 18, 2006, 8:08:50 PM12/18/06
to
From: Christopher Latif <christ...@bredband.net>
Subject: Problem installing Ruby/Tk
Date: Mon, 18 Dec 2006 22:03:27 +0900
Message-ID: <4d8aa1df7483d251...@ruby-forum.com>

> 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 Latif <christ...@bredband.net>
Subject: Re: Problem installing Ruby/Tk
Date: Tue, 19 Dec 2006 01:50:13 +0900
Message-ID: <184a26d86bc891d8...@ruby-forum.com>
> 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.
--
Hidetoshi NAGAI (na...@ai.kyutech.ac.jp)

Christopher Latif

unread,
Dec 19, 2006, 7:15:40 AM12/19/06
to
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.

Paul Lutus

unread,
Dec 19, 2006, 12:48:11 PM12/19/06
to
Christopher Latif 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.

Christopher Latif

unread,
Dec 23, 2006, 6:46:43 AM12/23/06
to

> 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?

Vincent Fourmond

unread,
Dec 23, 2006, 7:28:06 AM12/23/06
to

make; make install

You might need

make clean

before, see if it works without.

Vince

--
Vincent Fourmond, PhD student
http://vincent.fourmond.neuf.fr/

0 new messages