| |||||||||||
integrate Tcl/Tk - C++ Posted by triclosan (triclosan), 18 October 2003 I have a ploblem!How integrate Tcl/Tk and C++. For example - how use Tk interface with C++ console applications. Code:
For example how bind string 'Helo' with Tk field "Entry". Posted by admin (Graham Ellis), 18 October 2003 Have a look at "Tcl and the Yk toolkit" by John Ousterhout - the author of the Tcl language ... http://www.wellho.net/book/0-201-63337-X.html; there's about 100 pages there on the integration of Tcl and Tk into a C application, and it should work just as well for C++. Tcl was designed as a library to integrate a scripting language into C ... it's not that hard to do.Posted by triclosan (triclosan), 19 October 2003 Thanks!But I need simple example of this integrate. It can be not only for C++. If anybody can wrote anything for C please do it.. Posted by admin (Graham Ellis), 19 October 2003 Here's a simple example of extending Tcl by building an application with an interpretter in C, and extending the application with a command written in C.Code:
It's the start of what you need; to bind your text field to a variable in C, you need to learn about the various variable types and data transfers between C and Tcl, and (as per previous post) the best way to find this is from John Ousterhout's book. Please do post a follow up if you have any questions that relate to the examples in the book - I think there's only the one edition, so if you refer me by page number I'll be able to get straight to the point. Posted by triclosan (triclosan), 20 October 2003 I have a ploblem.My gcc compiler give : [root@localhost CPP_igor]# gcc tcl.c /tmp/ccYRRwKN.o: In function `main': /tmp/ccYRRwKN.o(.text+0x5b): undefined reference to `Tcl_CreateInterp' /tmp/ccYRRwKN.o(.text+0x79): undefined reference to `Tcl_CreateCommand' /tmp/ccYRRwKN.o(.text+0x8f): undefined reference to `Tcl_EvalFile' collect2: ld returned 1 exit status [root@localhost CPP_igor]# Please help to compile this source... Posted by admin (Graham Ellis), 20 October 2003 Do you have the Tcl header file (tcl.h) loaded and in the correct path for gcc?Posted by triclosan (triclosan), 20 October 2003 Yes I have it.And I think tcl.h currently included into source... Posted by admin (Graham Ellis), 21 October 2003 OK ... are you specifying any command line options to your compile to load in the tcl library (such as -ltcl)?Posted by triclosan (triclosan), 21 October 2003 I add command line options and source is compiled correctly.But now out is "Segmentation fault"... Posted by admin (Graham Ellis), 22 October 2003 I'm guessing that you're running the program without any command line parameters. This example is a tiny piece of code that's written to be easy to follow and understand, and it does not do any error checking. Have a look at the code and work out what you need Posted by triclosan (triclosan), 22 October 2003 Thanks I try.But i still don't understand how it working. Anyway thanks a lot! Posted by nash4 (nash4), 26 September 2007 hellosorry for my poor english, like you can see i'm not native speaker i was looking at a topic with you and triclosan i have some problems with integration of tcl/tk with c too first i use code::blocks ide with mingw32 under windows i'm medium programmer with c but beginner with code::blocks, and with gcc...(i never make a make manualy... ) i try to use the common dialogues of tcl/tk in a c program i just found .lib but it seems that mingw32 need .a library (but not always...) do i need .lib or .a ? i try to use reimp.exe, that reimplement the .lib like a .a but it seems odd... the weight is not the same ( 192 ko for tcl84.lib vs 664 ko for libtcl84.a may be a problem) thus where can i found precompiled .a for windows i try to found on web, to the site of sourcenet, but i dont find... i would to compile tcl/tk thus i download source files but it was "a little" more complicated that i thought...^^ too much for me indeed, i don't know where is the beginning^^ it is a very big projet... thus i'm not sure of my reimplementation by reimp.exe and once i have them, how to install, and how to configure ? (path that i have to give to the linker, compilator option, ...)(i gave every things that i can, but it seems that it doesn't make links...i certainly make a stupid thing but where) it say Code:
it's very difficult to found information on tcl/tk with c on the web (and under windows and code::blocks !!!) i compiled the code that you gave to triclosan with adding this little code: Code:
the console program said: Can't find usable init.tcl in the following directories: this probably means that Tcl wasn't installed properly i try to reinstall tcl/tk ( activetcl pack ) but the problem is still the same i hope that i was enought clear, sorry if my questions are so beginner level, but i don't found answers for my questions anywhere thanks a lot Posted by smcool89 (smcool89), 13 November 2007 Hello I am new to tcl and to this forum also. I saw this forum i found that i found that the error mentioned in the questions from the man are exactly the same as mine.. I have a small program written in c interacting with tcl and i don't know how to compile and use it .. I have tried several ways mentioned at different places and have got some errors .. below is the code and the errors i got while compiling it.. [sam@sam learning_c++_tcl]$ g++ c_tcl7.c /tmp/ccgOFffj.o(.text+0x2d): In function `main': : undefined reference to `Tcl_CreateInterp' /tmp/ccgOFffj.o(.text+0x43): In function `main': : undefined reference to `Tcl_EvalFile' collect2: ld returned 1 exit status Then i compiled it in the following way : [sam@sam learning_c++]$ g++ c_tcl7.c -ltcl /usr/bin/ld: cannot find -ltcl collect2: ld returned 1 exit status Please guide me how to remove the error and run the code perfectly. thanks Posted by admin (Graham Ellis), 13 November 2007 Hello. See answer in other thread. (There's no need to ask a question twice ...)This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |