user1985580
user1985580

Reputation: 61

Accessing TCL libraries

I am new to TCL and am struggling with accessing other modules. The SOURCE command helped me include other code that I have written in a TCL program. However, I think I have a problem with accessing libraries of code.

For example, when I reference a math function, it is not found. I think there must be something I need to do to include where the math library is on my computer in the search for a program called via tchsh85.

invalid command name "::math::statistics::mv-ols"

None of these directories exist on my computer:

info library= C:/Tcl/lib/tcl8.5
auto_path= C:/Tcl/lib/tcl8.5 C:/Tcl/lib c:/tcl/lib/teapot/package/win32-x86_64/lib               c:/tcl/lib/teapot/package/tcl/lib
tcl library= C:/Tcl/lib/tcl8.5
auto_index= source C:/Tcl/lib/tcl8.5/word.tcl
auto_index= source C:/Tcl/lib/tcl8.5/tm.tcl
auto_index= source C:/Tcl/lib/tcl8.5/tm.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/parray.tcl
auto_index= source C:/Tcl/lib/tcl8.5/history.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/history.tcl
auto_index= source C:/Tcl/lib/tcl8.5/package.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/history.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/word.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/word.tcl
auto_index= source C:/Tcl/lib/tcl8.5/package.tcl
auto_index= source C:/Tcl/lib/tcl8.5/tm.tcl
auto_index= source C:/Tcl/lib/tcl8.5/auto.tcl
auto_index= source C:/Tcl/lib/tcl8.5/auto.tcl
auto_index= source C:/Tcl/lib/tcl8.5/auto.tcl
auto_index= source C:/Tcl/lib/tcl8.5/auto.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/auto.tcl
auto_index= source C:/Tcl/lib/tcl8.5/history.tcl
auto_index= source C:/Tcl/lib/tcl8.5/auto.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/history.tcl
auto_index= source C:/Tcl/lib/tcl8.5/package.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/auto.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/auto.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/history.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/tm.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/auto.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/auto.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/word.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/package.tcl
auto_index= source C:/Tcl/lib/tcl8.5/auto.tcl
auto_index= source C:/Tcl/lib/tcl8.5/history.tcl
auto_index= source C:/Tcl/lib/tcl8.5/package.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/word.tcl
auto_index= source C:/Tcl/lib/tcl8.5/history.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/auto.tcl
auto_index= source C:/Tcl/lib/tcl8.5/history.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl
auto_index= source C:/Tcl/lib/tcl8.5/tm.tcl
auto_index= source C:/Tcl/lib/tcl8.5/tm.tcl
auto_index= source C:/Tcl/lib/tcl8.5/safe.tcl

Upvotes: 0

Views: 1294

Answers (2)

Donal Fellows
Donal Fellows

Reputation: 137567

The command that you want to succeed is:

package require math::statistics

You're not supposed to get the code by other ways (like a direct source) because you're then binding to the implementation of the package instead of the specification of it. That package is a part of the Tcllib collection, which you should install somewhere on your computer.

If you're using ActiveTcl, you want to do:

teacup update

That will install many packages and set up all the paths you require.

If you're using your own build, you'll have to download a copy of Tcllib for yourself and follow its installation instructions. I can't remember where it installs to by default on Window, but let's say it is to C:\Tcl\lib\Tcllib (with the actual packages in subdirectories of that): in that case you'd make the packages available to Tcl by doing:

lappend auto_path C:/Tcl/lib/Tcllib

If you're making a redistributable executable, there's additional techniques. Ask another question in that case.

Upvotes: 2

TrojanName
TrojanName

Reputation: 5355

::math::statistics is part of TCLlib. To check if you have it installed, type

package require tcllib

and if it is installed, it will tell you the version number. If it's not installed, you can use Teacup to install it for you.

Upvotes: 0

Related Questions