WJG (13/Nov/09) I d'know, maybe its because its friday the 13th? With the prospect of working on a new project coming along that needs me to access libraries crafted in C++ I thought that I'd take a look of at what resources are listed on the wiki on building Tcl entensions in C++. Ok, there are a few offerings there cpptcl, for instance, but, it fails to compile and is, somewhat dated. Can anyone recommend anthing out there a little more useful?
WJG I was thinking of producing a tcl wrapper around the djvulibre package which is written in C++. So, basically I want to easily, build a tcl package in C++.
WJG I've briefly looked at it. What I was looking to find was a simple template that can be modified. I'd rather build in C++ and then load into Tcl rather than simply expose tcl to any library functions. Briefly searching around at other packages that bridge Tcl and C++ libs I looked at Qtcl, which provides Tcl bindings to the Qt libraries. The solution there was to produce a new interpreter with Tcl-ish scripting rather that to produce a loadable package. I think that I'll take another look at cpptcl, the only real error that threw my compiler was exception handling. Any suggestions greatfully welcomed!
CJL - SWIG does get you "build in C++ and then load into Tcl". It can, depending on how your existing source code is written, be as simple as pointing SWIG at your .h file. It will generate constructors/destructors and setters/getters. I suggest you have a read of Tcl and SWIG as a C/C++ Development Tool
AK - 2009-11-13 19:02:16
The only C++ package I am ware of is Metakit, and building that is bit of a mess.
The tcl.m4 macros are ok with finding a C compiler, however finding a C++ compiler is not in there, IIRC.
stevel - 2009-11-14 20:06:15
See "Critcl does C++"
PhilMartin - 2009-11-16 05:48:00
I've used C++/Tcl extensively, and I find it excellent. Very easy to write extensions in C++, or embed interpreters. It supports exposing procs and classes.
WJG I've taken another look at C++/Tcl and can see that this is the most likely way forward. I've reconfigured the makefile to suit my system and most of the tests/examples are working well -so far!
RFox - 2009-11-23 12:50:41
NSCLSpecTcl is one large Tcl extension as is epicstcl... there's nothing really magic about using C++ as an extension language. What I _did_ do is wrap chunks of the API in a class library/application framework so that using it from C++ is more C++-ish.
AMG: Are you sure there's no magic? I thought you'd need extern "C" declarations on your *_Init(), *_SafeInit(), *_Unload() and *_SafeUnload() functions.