Skip to content
zdia edited this page Dec 10, 2010 · 9 revisions

Example: Creating a shared library f32 for the Twofish algorithm

The C code for the extension is in the file f32-critcl.tcl

Preparation:

Download the critcl files:

http://www.equi4.com/pub/sk/critcl2.kit
http://www.equi4.com/pub/sk/critcl.kit

Action:

tclkit-executable-name critcl2.kit -lib f32-critcl.tcl

e.g.:

$ tclkit critcl2.kit -lib f32-critcl
Target:   ix86-linux
Source:   f32-critcl.tcl 
Library:  f32-critcl.so

We rename the library to:

f32-Linux-x86.so

Cross compiling a Windows library:

Xmingw offers cross compiling on a Unix host. So we install it and inform Critcl about the cross-compile environment, e.g.:

export PATH="~/mingw32/i386-mingw32/bin:$PATH"

Note:

tclkit critcl2.kit -lib f32-critcl.tcl 

will not recognize the mingw compiler.

But critcl.kit works:

$ tclkit critcl.kit -lib f32-critcl
Cross compiling for Windows using Xmingwin
Source: f32-critcl.tcl 
Library: f32-critcl.dll

The library will be renamed to:

f32-Windows-x86.dll

MacOSX

We have to work on a Mac. We need three files from our Linux host:

  • tclkit-darwin-univ-aqua
  • critcl.kit
  • f32-critcl.tcl

Then we can create the Mac version:

$ ./tclkit-darwin-univ-aqua critcl.kit -lib f32-critcl.tcl 
Source: f32-critcl.tcl 
Library: f32-critcl.dylib

which will be renamed to:

f32-Darwin-x86.dylib