Narek
Narek

Reputation: 39881

How to extend TCL with C++?

Can I write a C++ code that can be compiled and used for extending TCL (I don't mean calling an executable file)? Can I describe some classes, functions and use them for in my TCl code by calling the compiled (.so or .a file) C++ code? If yes, then please explain me schematically how it is being done.

Upvotes: 2

Views: 5930

Answers (4)

Narek
Narek

Reputation: 39881

http://cpptcl.sourceforge.net/ It is a C++ wrapper of Tcl C API and very convenient to use, well documented. I tell this from my personal experience.

C++/Tcl is a library that allows to easily integrate C++ and Tcl. If you write programs in both languages, you will find it to be extremely helpful.

The C++/Tcl library was inspired by the Boost.Python library and was designed to provide a similar interface.

Currently, the C++/Tcl library offers the following features: Support for both extending Tcl with C++ modules and embedding Tcl in C++ applications. Possibility to expose free C++ functions as commands in Tcl. Possibility to define classes and class member functions, visible in Tcl in the style similar to SWIG wrappers. Possibility to manipulate Tcl lists and objects from the C++ code.

Upvotes: 3

Donal Fellows
Donal Fellows

Reputation: 137567

You might consider using SWIG to build the binding. It doesn't produce a particularly idiomatic Tcl interface (Tcl and C++ being rather different languages after all) but it does allow you to get working very rapidly.

Upvotes: 2

Jackson
Jackson

Reputation: 5657

Have a look at this question, it shows how to create an Tcl extension using Visual C++ under Windows. The process under Unix is similar but you create a Unix .so library rather than a .dll.

Upvotes: 2

Vijay Mathew
Vijay Mathew

Reputation: 27164

You can extend TCL with C++. Especially have a look at the Itcl++ tool.

Upvotes: 2

Related Questions