2

In my c++ program, I used Tcl library and linked libtcl8.5.so, but the target hosts don't have tcl8.5, so I copied the libtcl8.5.so and tcl8.5 dir which contains init.tcl there, and set the environmet variable TCLLIBPATH to path/to/copied/tcl8.5, but when my program call Tcl_Init, it failed and said “package not known”.

It seems the copied tcl8.5/ cannot be init correctly. How can I solve this problem?

zhangailin
  • 926
  • 2
  • 10
  • 20

1 Answers1

2

If you change the location of the script library directory (tcl8.5/ in your case), you need to tell the shared library part of Tcl where it is. You do this using the TCL_LIBRARY environment variable, which if set should contain the absolute path that is the location of that directory (technically, the directory that contains init.tcl). In a normal installation of Tcl, the correct location of that directory is baked directly into the shared library, but when you move things round (or when you are running Tcl's make test) the environment variable allows you to override.

You might wish to look into alternate packaging mechanisms; there have already been a few questions in the tag on this matter (but the usual favorite — a starkit — is probably not suitable for your case given the fact that the program is mainly C++).

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
  • 4
    You could use a basekit dll or stardll (http://wiki.tcl.tk/15969). There you could link the C++ app to a dll that also includes a VFS containing any scripts required. By default such an entity contains the Tcl core scripts already. – patthoyts Oct 17 '12 at 12:09