Ftcl: Deployment issues
There are a few things to be aware of when you use Tcl/Tk
in a Fortran program:
The easiest way to get the program to work is to use a directory
structure like the one shown below (for simplicity, shown as it appears
- part of the initialisation of Tcl is that the script init.tcl
is read. This must be located in one of the directories that Tcl
searches by default. (Currently, there is no way to set that list.)
- the same goes for Tk, which requires configuration scripts for all
of its widgets.
- the shared libraries or the dynamic link libraries must be available
via the proper channels: either on the path defined by the PATH
environment variable, or by LD_LIBRARY_PATH (SHLIB_PATH on some
... (other scripts)
... (scripts for the widgets)
Then set the PATH environment variable to include the directory
...\myprog\bin and, on Linux or UNIX, set the LD_LIBRARY_PATH
environment variable to include that same directory.
Though you need to keep these files on the same computer as your
program, there is no need to install Tcl/Tk on it: these files are
The Tcl libraries and script files do not need to be in the same
directory as the program itself. The DLLs or shared libraries must be
found in the path and the script files must be in a sibling directory
of the directory holding the DLLs or shared libraries.
Some details about the C implementation
This section provides some information on the way the interface between
the Tcl library (which is written in standard C) and Fortran is
C and Fortran both "mangle" the names of the routines. On some platforms
the actual calling conventions differ too and other complications arise
as well: these are all problems a programmer has to face when combining
two different languages, but they can be relatively easy dealt with
This is up to a point: the C compiler has no knowledge of what Fortran
compiler is used, and therefore some help must be provided - in the form
of a C preprocessor macro.
Currently, Ftcl supports the following platforms:
- SUN Solaris with native compilers
- GNU C and g77 or g95 Fortran (all platforms)
- Windows with MSVC and Compaq Visual Fortran
- Windows with MSVC and Lahey Fortran
- Windows with MSVC and g95 Fortran
The SUN compiler is automatically recognised via the predefined macro
The GNU C compiler is not automatically recognised:
- If you are using the g95 Fortran compiler, define the macro "G95"
when compiling the C code
- If you are using the g77 FORTRAN 77 compiler, define the macro "G77"
On the Windows platform the MicroSoft Visual C/C++ compiler is often
used, but for the Fortran compiler several options are possible with
that C compiler. The C compiler in this case determines the name
mangling and the calling convention. So, one macro, "WIN32", covers all
- Other combinations are possible, of course, it is a matter of
defining the right translations.
- The Fortran compiler may need specific information too: for instance
the Lahey compiler requires the flags "-ml msvc" so that it can prepare
for linking with C routines compiled by the MSVC compiler (-ml is the