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

Is Tcl/Tk supported on Ubuntu Desktop Linux?

876 views
Skip to first unread message

Alwyn Teh

unread,
Jan 22, 2022, 5:38:02 PM1/22/22
to
I just installed the latest Ubuntu Desktop 21.10 and built Tcl.

But Tk is not building on Ubuntu from the unix directory.

alteh@alteh-VirtualBox:~/dev/Tcl-Tk/tk8.6.12/unix$ make
gcc -c -I/home/alteh/dev/Tcl-Tk/tk8.6.12/unix/../unix -I/home/alteh/dev/Tcl-Tk/tk8.6.12/unix/../generic -I/home/alteh/dev/Tcl-Tk/tk8.6.12/unix/../bitmaps -O2 -pipe -Wall -Wpointer-arith -fPIC -DBUILD_tk -I/home/alteh/dev/Tcl-Tk/tcl8.6.12/generic -I/home/alteh/dev/Tcl-Tk/tcl8.6.12/unix -DPACKAGE_NAME=\"tk\" -DPACKAGE_TARNAME=\"tk\" -DPACKAGE_VERSION=\"8.6\" -DPACKAGE_STRING=\"tk\ 8.6\" -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DUSE_THREAD_ALLOC=1 -D_REENTRANT=1 -D_THREAD_SAFE=1 -DHAVE_PTHREAD_ATTR_SETSTACKSIZE=1 -DHAVE_PTHREAD_ATFORK=1 -DTCL_THREADS=1 -DMODULE_SCOPE=extern\ __attribute__\(\(__visibility__\(\"hidden\"\)\)\) -DHAVE_HIDDEN=1 -DHAVE_CAST_TO_UNION=1 -DTCL_SHLIB_EXT=\".so\" -DNDEBUG=1 -DTCL_CFG_OPTIMIZED=1 -D_LARGEFILE64_SOURCE=1 -DTCL_WIDE_INT_IS_LONG=1 -DHAVE_SYS_TIME_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_INTPTR_T=1 -DHAVE_UINTPTR_T=1 -DHAVE_PW_GECOS=1 -DXKEYCODETOKEYSYM_IS_DEPRECATED=1 -DUSE_TCL_STUBS -fno-lto /home/alteh/dev/Tcl-Tk/tk8.6.12/unix/../generic/tkStubLib.c
In file included from /home/alteh/dev/Tcl-Tk/tk8.6.12/unix/../generic/tkPort.h:21,
from /home/alteh/dev/Tcl-Tk/tk8.6.12/unix/../generic/tkInt.h:19,
from /home/alteh/dev/Tcl-Tk/tk8.6.12/unix/../generic/tkStubLib.c:14:
/home/alteh/dev/Tcl-Tk/tk8.6.12/unix/../generic/tk.h:99:13: fatal error: X11/Xlib.h: No such file or directory
99 | # include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:1168: tkStubLib.o] Error 1
alteh@alteh-VirtualBox:~/dev/Tcl-Tk/tk8.6.12/unix$

Also, the built-in default Tck/Tk does not seem to be properly built and installed.

alteh@alteh-VirtualBox:~/dev/Tcl-Tk/tk8.6.12/unix$ wish
application-specific initialization failed: Can't find a usable tk.tcl in the following directories:
/usr/local/lib/tcl8.6/tk8.6 /usr/local/lib/tk8.6 /usr/lib/tk8.6 /usr/lib/tk8.6 /lib/tk8.6 /usr/library

This probably means that tk wasn't installed properly.

%

How can I get Tcl/Tk built and installed properly on Ubuntu please?

Robert Heller

unread,
Jan 22, 2022, 9:34:39 PM1/22/22
to
sudo apt install libx11-dev
--

Francois Vogel

unread,
Jan 23, 2022, 6:38:24 AM1/23/22
to
Le 22/01/2022 à 23:37, Alwyn Teh a écrit :
> I just installed the latest Ubuntu Desktop 21.10 and built Tcl.
>
> But Tk is not building on Ubuntu from the unix directory.
>

> /home/alteh/dev/Tcl-Tk/tk8.6.12/unix/../generic/tk.h:99:13: fatal error: X11/Xlib.h: No such file or directory
> 99 | # include <X11/Xlib.h>
> | ^~~~~~~~~~~~
> compilation terminated.

You probably need to install the libx11-dev package.

Regards,
Francois

gsal

unread,
Jan 24, 2022, 11:43:20 AM1/24/22
to
Don't the tk sources come with their own ./xlib/X11/Xlib.h ?
Maybe it is a matter of making sure that directory is in one of those "-I" (<--uppercase i) include paths?

Robert Heller

unread,
Jan 24, 2022, 12:07:12 PM1/24/22
to
At Mon, 24 Jan 2022 08:43:18 -0800 (PST) gsal <salg...@gmail.com> wrote:

>
> On Sunday, January 23, 2022 at 6:38:24 AM UTC-5, Francois Vogel wrote:
> > Le 22/01/2022 à 23:37, Alwyn Teh a écrit :
> > > I just installed the latest Ubuntu Desktop 21.10 and built Tcl.
> > >
> > > But Tk is not building on Ubuntu from the unix directory.
> > >
> > > /home/alteh/dev/Tcl-Tk/tk8.6.12/unix/../generic/tk.h:99:13: fatal error: X11/Xlib.h: No such file or directory
> > > 99 | # include <X11/Xlib.h>
> > > | ^~~~~~~~~~~~
> > > compilation terminated.
> > You probably need to install the libx11-dev package.
> >
> > Regards,
> > Francois
>
>
> Don't the tk sources come with their own ./xlib/X11/Xlib.h ?
> Maybe it is a matter of making sure that directory is in one of those "-I" (<--uppercase i) include paths?

That is a "fake" xlib/X11/Xlib.h for MS-Windows and MacOSX. Tk is written in
terms of XLib and under MS-Windows and MacOSX some of the XLib-isms are
"faked" in terms of MS-Windows or MacOSX GUI features. Under actual UNIX or
Linux, Tk uses the Xlib.h provided by X11. A typical Linux distro separates
the X11 runtime (shared) libraries from the X11 development stuff (header
file, link libraries, etc.). Commonly a normal Linux Desktop install just
installs the runtime. It is necessary to install the -dev (-devel under
RedHat-ish distros) packages if one plans on building tcl/tk from sources.

The OP *could* have just installed tcl and tk from the distro:

sudo apt install tcl tk

But I guess he wanted to build from source...

>
>
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
hel...@deepsoft.com -- Webhosting Services

lew-e jones-ayres

unread,
Feb 22, 2023, 6:48:17 PM2/22/23
to
Hi I know this is an old post but I've been through every forum trying to fix this issue. I need tkinter for my ubuntu virtual machine, I've checked im in the correct python, installed all the packages including the one Robert suggested (though installing from distro so I shouldn't have to). Nothing. I even tried manually copying the tk8.6 directory into lib and tcl8.6, no effect.
Just:

lewie@lewie-virtual-machine:~/Downloads$ python3

Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> tkinter._test()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/tkinter/__init__.py", line 4586, in _test
root = Tk()
File "/usr/lib/python3.10/tkinter/__init__.py", line 2299, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable tk.tcl in the following directories:
/usr/local/lib/tcl8.6/tk8.6 /usr/local/lib/tk8.6 /usr/lib/tk8.6 /usr/lib/tk8.6 /lib/tk8.6 /usr/library

This probably means that tk wasn't installed properly.

>>>

incidentally the /tk8.6/ dir only contains "pkgIndex.tcl"
in case that's what's wrong.

Any help would be great

Lewie

Christian Gollwitzer

unread,
Feb 23, 2023, 2:12:12 AM2/23/23
to
Am 23.02.23 um 00:48 schrieb lew-e jones-ayres:
This is strange at the very least. Besides pkgIndex.tcl, there should be
a folder with a lot of support files (scripts, icons, demos,...). It is
basically this stuff:

https://github.com/tcltk/tk/tree/main/library

So maybe the package from your distro is simply broken? Or, the package
from the distro is installed somewhere else, and Tcl picks up a broken
version first and can't find the right version. You can check the path
where Tcl looks for packages like this:

(base) Apfelkiste:~ chris$ python3
Python 3.8.8 (default, Apr 13 2021, 12:59:45)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> interp=tkinter.Tcl()
>>> interp.eval("set auto_path")
'/Users/chris/bin/anaconda3/lib/tcl8.6 /Users/chris/bin/anaconda3/lib'
>>>

and afterwards try to load Tk manually:

>>> interp.eval("package require Tk")
'8.6.10'

then this should tell you, which version was loaded:

>>> interp.eval("package ifneeded Tk 8.6.10")
'load /Users/chris/bin/anaconda3/lib/libtk8.6.dylib Tk'
>>>

Christian





0 new messages