![]() |
|
|
If you want to build Tcl with Borland C++ 5.5 (C++ Builder 5 or the free command line compiler), get this package. It contains everything you need in the following directory structure and files:
. ChangesBC55.txt: Summary of all changes
|
|
|___ generic
| tcl.horg: the original file tcl.h
| tcl.h: tcl.h modified to support BC 5.5
|___ win
tclWinPort.horg the original
tclWinPort.h modified to support BC 5.5
tclWinPipe.corg the original
tclWinPipe.c modified to support BC 5.5
makefile.bc55 the makefile for BC 5.5
buildtestbat.tcl support for the regression tests (see below)
clean.tpl template for the clean-up script
You can unzip it into your source directory tcl8.3.3. It is not really necessary to back up the files I modified, because the originals will be copied, too, as *.*org. Edit the makefile to adapt to your paths and off you go.
Please consider this a temporary solution. If - or rather when (?) - Borland support will have been added to the normal Tcl distribution, you should get the sources from there. Since there remain some questions to be decided (have a look at ChangesBC55.txt if you're technically inclined), it is possible that the final version might differ from the one currently posted here.
You can also get the version for Tcl 8.3.2.
If you run the regression tests by just saying
make test
after having made everything else you're up to an unpleasant surprise (at least under Win95): Lots of error messages and eventually the test shell itself gets so messed up it doesn't even find the remaining test files anymore.
As it turned out this is more a problem of the test shell than of the Borland generated Tcl DLL (the same thing happens with the official version). However, it is possible to run all the tests by passing the test shell just one test script at a time. Since you wouldn't want to call the shell 120 or so times you can execute the script buildtestbat.tcl (documentation is included within) which will create a batch file testall.bat that does all this calling. It creates another batch file testone.bat which you can use to run just one particular test. Finally it creates a script cleantst.tcl which removes all result files that contain no errors - you wouldn't want to check all of them by hand.
You will find that the Borland generated DLL produces a few errors more than does the official (VC++ generated) version. Have a look at those erros and at what was tested to see whether you have to care. I don't, so I won't spend time on fixing those marginal points.
If you are writing pure Tcl scripts you couldn't care less.
If you are using the Borland compiler to create a C extension to Tcl you will have problems linking your extension with the original (Microsoft) DLL. This is a general problem not restricted to Tcl but you can solve this by following the steps below.
If your extension works fine from the start you're fine. But what happens if things don't work as expected? If your program blows up? If maybe you don't even know whether the problem lies on the Tcl or the C side?
OK, at this point you get out the debugger. But when you step inside the Tcl code all of a sudden you get into the Microsoft DLL - which is like running against a wall: all you see is assembler code. But from now on, with your Borland generated version of Tcl, you can continue.
In the end, when everything is working, you have the choice whether to ship your program with the official Tcl DLL or with the Borland version.
Microsoft and Borland build their DLLs differently, so linking Borland generated code with a Microsoft generated DLL is alway a hassle. I spent some time on this problem, and with the help of a Borland C++ guru (Harold Howe, www.bcbdev.com, see the articles section there) I found an easy way that seems to solve this question for the time being - up to the day of course, where new incompatibilities will show up. Here is a description on how to to it. The procedure uses Borland tools and - fitting, I think - a small Tcl script.
The following examples might prove useful to you. They all come with a makefile to be used with the Borland compiler. But this does not mean that they wouldn't work with VC++. I just don't have access to VC++ and so I cannot provide you with project files.
However, this shouldn't be too big a problem. If you work with VC++ you will probably know how to create a project and use an already existing source file (at most two files in the examples). That should be it - I suppose.
This is currently available:
Several examples on how to link C with
Tcl/TK - just what I found looking around. They can all be built using Borland C++ 5.5 -
but not all of them work as expected. No big deal: I am sure that they worked with the
version of Tcl they were originally written for - given the quality of the Tcl material
you normally find. Since their sole purpose is to show how to combine Tcl and C, these
deficiencies are not too serious in my opinion.
Or you might use one of those "erronous" examples to have a go at debugging a C
/ Tcl combination. Maybe not a bad idea - they're only small examples, nothing
complicated, no possibility to get lost. If you want to give it a try, take the example
"tclmain" and find out why the "plus1" command does not work as
expected.
Some more examples on how to combine Tcl and C, this time using (X)MkTclApp - an easy way to get a stand-alone program containing both your C code and your Tcl scripts.
I added some examples of my own: If you combine Tcl and C you will surely at some point want to pass (Tcl) lists to your C code - as well as expecting such lists as the result of the processing you do on the C side. Here is one way how to do it.
If all you want is to extend Tcl by putting functionality written in C into a DLL that Tcl can load, here is an example that shows it: Once without, once with using (X)MkTclApp. The file readme.txt contains a rather detailed description and - as usual - there is makefile for the Borland compiler.
I posted a message concerning this topic on comp.lang.tcl on Dec. 4, 2000. Here is the respective hit count:
| This (main) page |
Link Borland with Microsoft |
Misc. examples (1) |
Use MkTclApp (2) |
Pass lists (3) |
| 17779 | 6174 | 8050 | 3042 | 2407 |
Things change fast these days. Want to be informed if changes had been necessary (bugs discovered, new version of ...) or additional material is available (e.g. not only C & Tcl, but also VCL & Tcl) ?
Version info: All examples (if applicable) are based on Tcl/TK 8.3.2, Borland C++ 5.5 (or C++ Builder 5) and MkTclApp 3.9.
Copyright © Helmut Giese, email: hgiese@ratiosoft.com
Parkstr. 41, 34119 Kassel, Tel.: 0561 - 766 59 50, Fax: 0561 - 766 59 51
Königstor 59, 34119 Kassel, Tel.: 0561 - 739 35 30, Fax: 0561 - 739 35 31
Web Design von Bianca Engler: email
internet