Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
errors while embedding tcl in c

Posted by pavan (pavan), 23 November 2006
Code:/* Well House Consultant - building TCL into a C application */
/* Extended Tcl - an extra command written in "C" */

#include <stdio.h>
#include <tcl.h>

int equal(ClientData notneededhere, Tcl_Interp *ipointer,
  int eq_argc, char *eq_argv[]) {
  /* Should check argument count! */
  if (strcmp(eq_argv[1],eq_argv[2]) == 0) {
  ipointer->result = "1";
  } else {
  ipointer->result = "0";
  }
  return TCL_OK;
}

main (int argc, char *argv[]) {

  Tcl_Interp *myinterp;
  int status;

  printf ("Your Tcl Program will run ... \n");

  myinterp = Tcl_CreateInterp();
  Tcl_CreateCommand(myinterp,"same",equal,
  (ClientData) NULL,
  (Tcl_CmdDeleteProc *) NULL);
  status = Tcl_EvalFile(myinterp,argv[1]);

  printf ("Your Tcl Program has completed\n");
}
 
 
i m trying to run this code in qnx environment when i compile this prog

it gives the following errors

gcc tcl.c -ltcl -lm

/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
i have installed tcl8.3.5 version on qnx which is working fine.

i have included tcl.h file from the above installed tcl directory.

plz tell me how to compile this code

thanks in advance

Posted by admin (Graham Ellis), 23 November 2006
I suspect that you've a problem in your library include path - probably something like a -I or -L option needed on your GCC line.   Have a look around for the libraries to see where they are, and then add the appropriate option.

By the way ... you might like to add a -o option too unless you want your executable to be called a.out  

Posted by pavan (pavan), 24 November 2006
Thanks for ur reply

u think that their is a problem in my tcl.h file?if so can u tell me where i can find tcl.h and appropriate lib files which can be used on QNX 6.3

Posted by admin (Graham Ellis), 24 November 2006
No - I can't tell you where those files are on your system - it depends how and where they're installed.  That's why I suggest you look for them.  By the way, the error message indicates to me that tcl.h has ben found and the problem you've got is at a later stage with the libraries.

Posted by pavan (pavan), 24 November 2006
thanks
what i meant was where can i find tcl.h and library files on the net for QNX 6.3(plz give the link for the same)

Posted by pavan (pavan), 29 November 2006
Can anyone tell me the detailed procedure for integrating tcl with C i.e i need to call a tcl script from c source code.i am using qnx as an operating system.
thanks in advance

Posted by pavan (pavan), 29 November 2006
when i compile the below code it works fine but when i build it gives the following errors

#include<stdlib.h>
#include <stdio.h>
#include <tcl.h>

int main(int argc, char *argv[]) {
Tcl_Interp *interp;
int code;
if (argc != 2) {
fprintf(stderr, "Wrong # arguments: ");
fprintf(stderr,"should be \"%s fileName\"\n",argv[0]);
exit(1);
}
interp = Tcl_CreateInterp();
code = Tcl_EvalFile(interp, argv[1]);
if (*interp->result != 0) {
printf("%s\n", interp->result);
}
if (code != TCL_OK) {
exit(1);
}
exit(0);
}



*** [/root/workspace/tcltest/x86/o/tcltest]
***[/root/workspace/tcltest/x86/o-g/tcltest_g]


Posted by pavan (pavan), 1 December 2006
PlZ Reply soon
it's very urgent



Posted by admin (Graham Ellis), 1 December 2006
Hello - I gave you pointers earlier on in this thread to help you find what you are looking for - I don't know your system, so that's really the best I can do.

We can, and do, answer questions at no charge from anyone and everyone, but there's a limit to how much time I can put into researching an answer.   For our customers - people who we have trained, or people ho have other contracts with us - we can (and do) find rather more time.

Pavan ... even though you're asking for a further urgent reply when we've already put some time in to help you, I can't find any record of any course that you've attended with us.   If you can let me know when / where you were with us, then I can spend an hour or two over the weekend looking to provide further help.  Otherwise, sorry, I can't put any more time in to this question.



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.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho