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

Can't find a usable init.tcl ...

593 views
Skip to first unread message

Peter

unread,
Apr 2, 2002, 10:49:54 AM4/2/02
to
Hello,

I have a problem, and I don't know how I can solve it.

I installed Tcl/Tk on my Windows2000 PC in the directory "D:\Tcl" (using
"ActiveTcl-8_3_3_8330.exe") .

My c++ files do compile without any problems, but when I want to run my
executable, I get the following error message :

------------------------------------------------
Can't find a usable init.tcl in the following directories :
{}{..................................................................}{..................................................................}........

{..................................................................}

This probably means that Tcl wasn't installed properly.
------------------------------------------------

I read somewhere I should use "Tcl_FindExecutable", but that doesn't
change anything.


I've listed my main()-routine below :

---------------------------------------------------
void main(int argc, char* argv[])
{
Tcl_Interp* interp;

Tcl_FindExecutable(argv[0]);

interp = Tcl_CreateInterp();

Tk_Main(argc, argv, Tk_AppInit);

Tcl_DeleteInterp(interp);

exit(0);
}
---------------------------------------------------

Does anyone know what can be the problem ?

Don Porter

unread,
Apr 2, 2002, 12:26:12 PM4/2/02
to
Peter wrote:
> Can't find a usable init.tcl in the following directories :
> {}{..................................................................}{..................................................................}........
>
> {..................................................................}
>
> This probably means that Tcl wasn't installed properly.

Does the error message really have all those dots in it? I doubt it,
which means you've censored the part of the error message most useful
in helping us help you.

> I read somewhere I should use "Tcl_FindExecutable", but that doesn't
> change anything.

That's often the answer to problems like this, yes.

> void main(int argc, char* argv[])
> {
> Tcl_Interp* interp;
>
> Tcl_FindExecutable(argv[0]);
>
> interp = Tcl_CreateInterp();

Tk_Main creates its own interpreter. This call to Tcl_CreateInterp and
the later call to Tcl_DeleteInterp do nothing useful. Remove them.

> Tk_Main(argc, argv, Tk_AppInit);

So what does your Tk_AppInit look like?

> Tcl_DeleteInterp(interp);
>
> exit(0);
> }

Supply the missing data from the error message and tell us what program
you are running (full path), and what OS you're using and we might be
able to help. Also, are any environment variables like TCL_LIBRARY
set?

--
| Don Porter Mathematical and Computational Sciences Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|

Peter

unread,
Apr 3, 2002, 2:51:06 AM4/3/02
to
Don Porter wrote:

> Peter wrote:
> > Can't find a usable init.tcl in the following directories :
> > {}{..................................................................}{..................................................................}........
> >
> > {..................................................................}
> >
> > This probably means that Tcl wasn't installed properly.
>
> Does the error message really have all those dots in it? I doubt it,
> which means you've censored the part of the error message most useful
> in helping us help you.

Can't find a usable init.tcl in the following directories :

{}{E:/My Libraries/lib/tcl8.3}{E:/My Projects/c/test/Program1/lib/tcl8.3}{E:/My Projects/c/test/lib/tcl8.3}{E:/My
Projects/c/test/lib/tcl8.3/library}{E:/My Projects/c/test/library}{E:/My Projects/c/test/.../tcl8.3/library}{E:/My Projects/c/.../tcl8.3/library}

This probably means that Tcl wasn't installed properly.

> > I read somewhere I should use "Tcl_FindExecutable", but that doesn't
> > change anything.
>
> That's often the answer to problems like this, yes.
>
> > void main(int argc, char* argv[])
> > {
> > Tcl_Interp* interp;
> >
> > Tcl_FindExecutable(argv[0]);
> >
> > interp = Tcl_CreateInterp();
>
> Tk_Main creates its own interpreter. This call to Tcl_CreateInterp and
> the later call to Tcl_DeleteInterp do nothing useful. Remove them.
>
> > Tk_Main(argc, argv, Tk_AppInit);
>
> So what does your Tk_AppInit look like?
>
> > Tcl_DeleteInterp(interp);
> >
> > exit(0);
> > }
>
> Supply the missing data from the error message and tell us what program
> you are running (full path), and what OS you're using and we might be
> able to help. Also, are any environment variables like TCL_LIBRARY
> set?

I'm using Windows2000.

I'm running my own Visual C++ program : "E:/My Projects/c/test/Program1/Release/Program1.exe".

Tcl/Tk is located in D:\Tcl.

I didn't set any environment variables, I thought the installation program must perform those actions.


Eric Taylor

unread,
Apr 3, 2002, 3:30:04 AM4/3/02
to
Since you're on windows, you don't perchance have a copy of the
tcl/tk dlls in your .exe's working directory do you? I think if you do, you
will end up with [info library] pointing at your local dlls instead of
where it wants to point, at the library directory where the installed tcl/tk
dlls live. I got this or something similar when they were in my local dir.

In visual C package there is a depends program. Point it at your exe
and see where it thinks it's going to find it's dlls. Sometimes you
can do a "view dependencies" with a right click on an .exe file.

good luck
eric

David Gravereaux

unread,
Apr 3, 2002, 4:26:22 AM4/3/02
to
Eric Taylor <e...@rocketship1.com> wrote:

>In visual C package there is a depends program. Point it at your exe
>and see where it thinks it's going to find it's dlls. Sometimes you
>can do a "view dependencies" with a right click on an .exe file.

Yeah, that's dumpbin. Use the /dependents switch.


Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

D:\tomasoft_WS\tomahawk\out\Release\win32-ix86>prompt=$g

>c:\dev\devstudio60\vc98\bin\vcvars32
Setting environment for using Microsoft Visual C++ tools.
>dumpbin /dependents tmhwkGUI.exe
Microsoft (R) COFF Binary File Dumper Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.


Dump of file tmhwkGUI.exe

File Type: EXECUTABLE IMAGE

Image has the following dependencies:

KERNEL32.dll
USER32.dll
COMCTL32.dll
MSVCRT.dll
MSVCP60.dll
ADVAPI32.dll

Summary

1000 .data
2000 .rdata
2000 .rsrc
5000 .text

>


Odd. I'm using Tcl in it... Oh, I'm using Stubs instead of icky load-time OS
supplied dynamic linking. That's why Tcl doesn't show itself as a dependent.

After doing a registry search for where Tcl is, it then calls LoadLibrary() on
it. init.tcl has no problems loading as tcl knows where itself is by using it's
own instance handle. Stubs at the application level is a wonderful thing. I
really like it.

http://cvs.sf.net/cgi-bin/viewcvs.cgi/tomasoft/tes/src/win/winFindTcl.cpp?rev=1.2&content-type=text/vnd.viewcvs-markup
http://cvs.sf.net/cgi-bin/viewcvs.cgi/tomasoft/tes/src/win/winTclEventSystemInt.cpp?rev=1.5&content-type=text/vnd.viewcvs-markup

If, by chance, you are using static libraries for Tcl and Tk, they are very
sensitive to knowing where TCL_LIBRARY is located. You might have to hard-code
info right in the exe with something like this:

#include <tcl.h>

int
main (int argc, char *argv[])
{
Tcl_Interp *interp;
char cmd[] = "puts \"hello world!\"";


/*
* Tcl_FindExecutable has the important side effects of initializing
* the UTF-8 encoding subsystem by finding the Tcl encoding files.
*/

Tcl_FindExecutable(argv[0]);

interp = Tcl_CreateInterp();

/*
* Setting the tcl_library variable fixes the location of the Tcl script
library.
* If you do not want to predetermine this location, then you can install
the binary
* in the "standard location" and the Tcl runtime will find the script
* library automatically. If the Tcl script library is
* ...somewhere/TclPro1.4/lib/tcl8.3
* then the standard location for the executable is in
* ...somewhere/TclPro1.4/win32-ix86/bin
*/

Tcl_SetVar(interp, "tcl_library", "C:/PROGRAM FILES/TCLPRO1.4/lib/tcl8.3",
TCL_GLOBAL_ONLY);

if (Tcl_Init(interp) != TCL_OK) {

/*
* By the way, if you do not care about the "unknown" command and other
features
* added by the init.tcl script library, you don't need to even call
Tcl_Init,
* nor set up the tcl_library variable as above.
*/

puts(Tcl_GetStringResult(interp));
return 1;
}

/*
* Run some Tcl. Another useful API here is Tcl_EvalFile to run a script
from a file.
*/

Tcl_Eval(interp, cmd);

Tcl_DeleteInterp(interp);
Tcl_Finalize();
return 0;
}

--
David Gravereaux <davy...@pobox.com>
[species: human; planet: earth,milkyway,alpha sector]
Please be aware of the 7.5 year ping times when placing a call from alpha centari

Don Porter

unread,
Apr 3, 2002, 11:54:29 AM4/3/02
to
Peter wrote:
> I'm using Windows2000.
> I'm running my own Visual C++ program :
> "E:/My Projects/c/test/Program1/Release/Program1.exe".
> Tcl/Tk is located in D:\Tcl.

So there should be a file D:\Tcl\bin\tcl83.dll . And the launching of
your program should cause that DLL to be loaded.

> Can't find a usable init.tcl in the following directories :

> {}{E:/My Libraries/lib/tcl8.3} ...

It appears that instead, there is a file E:\My Libraries\?\tcl83.dll
(where ? might be "bin") and the launching of your program is
launching it instead.

Correct your development environment so that the right DLL is loaded,
and the problem should be solved.

If that's not feasible, you can work around the problem by setting
the environment variable TCL_LIBRARY to D:\Tcl\lib\tcl8.3 .

Eric Taylor

unread,
Apr 3, 2002, 10:45:33 PM4/3/02
to
I think dumpbin is another program. The depends program
is the dependency walker. Once in, you need to right click a dll and
select full path so you can tell "which" tcl83.dll you are using.

Here's the promo page for depends:

Why use Dependency Walker?

Have you ever...


...ran LINK /DUMP or DUMPBIN to determine the imports or exports of a module?
...wondered what minimum set of files are required to run a particular application or load a particular DLL?
...wondered why a certain module was being loaded with a particular application?
...wanted to remove all dependencies for a given module?
...wanted to know the complete path of all the modules being loaded for a particular application?
...wanted to know all the base addresses of each module being loaded for a particular application?
What about versions?
Or maybe machine types?

...received one of the following errors...

The dynamic link library BAR.DLL could not be found in the specified path...
The procedure entry point FOO could not be located in the dynamic link library BAR.DLL.
The application or DLL BAR.DLL is not a valid Windows image.
The application failed to initialize properly.
The image file BAR.EXE is valid, but is for a machine type other than the current machine.
Program too big to fit in memory.

Then....

David Gravereaux

unread,
Apr 4, 2002, 11:20:03 PM4/4/02
to
Eric Taylor <e...@rocketship1.com> wrote:

>I think dumpbin is another program. The depends program
>is the dependency walker. Once in, you need to right click a dll and
>select full path so you can tell "which" tcl83.dll you are using.
>

Oh.. this thing is kinda fun:

LoadLibraryA("C:\PROGRA~1\Tcl\bin\tcl84.dll") called from "TMHWKGUI.EXE" at
address 0x004021AB.
Loaded "TCL84.DLL" at address 0x10000000. Successfully hooked module.
DllMain(0x10000000, DLL_PROCESS_ATTACH, 0x00000000) in "TCL84.DLL" called.
DllMain(0x10000000, DLL_PROCESS_ATTACH, 0x00000000) in "TCL84.DLL" returned 1
(0x1).
LoadLibraryA("C:\PROGRA~1\Tcl\bin\tcl84.dll") returned 0x10000000.
GetProcAddress(0x10000000 [TCL84.DLL], "Tcl_CreateInterp") called from
"TMHWKGUI.EXE" at address 0x00402266 and returned 0x1000B5A0.

I never used this thing before. I like the way you can view exports and trace
the way an app comes up.

0 new messages