how exactly do you do a binding?

sorry if this has been brought up before. I did lots of searching here before I decided to post. This is my first post here. I have used the site for some time now as a reference to the c++ libraries.


I am starting to look into trying to recreate some things I've seen. I have always seen api's that have "bindings" for other languages. That's a nice idea. I dont, however, know how to reproduce something like that. I'm not looking for a handout, I am looking for a point in the proper direction. Any links, or book references will be appreciated greatly.
Most other languages have an dynamic library that links using C functions.

To use that language from your C or C++ program, you need to #include the proper header files, load the library (.dll or .so) and call the correct functions to do what you want.

Bindings can work both ways (either using the other language from your C or C++ program or using compiled C or C++ functions from the other language), but the underlying system typically uses C functions and structures common to a dynamic library interface.

A well-known example of the Right Way of doing it is the Tcl/Tk suite.

For some starters, see here: http://wiki.tcl.tk/2074 (scroll down to "tclembed.c" for a simple example of embedding a Tcl interpreter in a C application).

See here http://wiki.tcl.tk/2265 for more about calling C functions from Tcl.

Also: http://wiki.tcl.tk/9836

Hope this helps get you started.
Last edited on
Topic archived. No new replies allowed.