Skip to content
Tcl Source Code View Ticket
Login

View Ticket

unable to link tcl in gcc

Closed / Invalid3010850fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2010-06-03 06:23:32
i hv attached a file with very few C code lines.i am able to compile but failed at linking the C code. on typing gcc tcl_c.c i am getting following erro in the terminal.
/tmp/ccPfH310.o: In function `main':
tcl_c.c:(.text+0x41): undefined reference to `Tcl_CreateInterp'
collect2: ld returned 1 exit status
OS platform:Linux 2.6.32-22-generic
I have successfully compiled and installed the Tcl.
prince-georgeplain2010-06-03 13:23:33
File Added - 376051: tcl_c.c
prince-georgeplain2010-06-03 13:25:35
i am using tcll8.4.18
flatwormplain2010-06-03 15:57:41
Not a bug: you most probably failed to link your code with libtcl of appropriate version.
Refer to http://wiki.tcl.tk/3474 , search for the word "embed" on wiki.tcl.tk and if this doesn't help ask for help on the comp.lang.tcl newsgroup (accessible via http://groups.google.com/group/comp.lang.tcl).

The bug may (and should) be closed.

P.S.
Also please note that Tcl 8.4.18 is very outdated as 8.5 is now the stable release and 8.6 is knocking at the door.
dkfplain2010-06-03 17:23:19
allow_comments - 1

1) Your code should call Tcl_FindExecutable before Tcl_CreateInterp (so that the Tcl library can initialize itself); see the documentation for how to do that.

2) Your bug is that you should also link against the Tcl library; compilers aren't smart enough to work that out for themselves (should be? Maybe, but definitely aren't). This might be as simple as adding -ltcl to where you call the compiler, or might also require telling the compiler/linker where to look (with -L/path/to/libdir).
Log in (anonymous is fine) to add a comment.

Attachments: