Can't seem to get tk compiled-in when using tclapp

Posted by rajiv on 2011-03-04 16:19

I have TDK5.2 with ActiveTcl-8.5 installed.
My system is
Linux opteron4 2.6.18-164.15.1.el5 #1 SMP Mon Mar 1 10:56:08 EST 2010 x86_64 x86_64 x86_64 GNU/Linux

I am trying to wrap my tk application with tclapp.
My command is

% tclapp -prefix ~/ActiveTcl-8.5/bin/base-tk8.5-thread-linux-ix86 -out myapp dbgMain.tcl *.tcl

I am afraid myapp is not getting the tk prefix compiled in.
myapp fails when it encounters any tk function call and quits
To confirm this, I added the following on top of my code

if {[info commands winfo] == ""} {
puts "tk was not initialized properly"

When I run myapp, I get
% myapp
tk was not initialized properly

Any help is much appreciated.

ActiveState Staff
Mon, 2011-03-07 09:41

As you are using a base-tk* basekit, Tk is already statically built in. However, you still need to initialize it properly with 'package require Tk' in your scripts. 'wish' does this for you, though it is considered good coding style to always include it where Tk is needed, as you see there are cases where it must be called.