Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie question: Problems compiling sample Tk program in C

188 views
Skip to first unread message

lht...@gmail.com

unread,
Sep 15, 2020, 3:22:38 PM9/15/20
to
Hello,

I'm relatively new to Tcl/Tk and tried to build a GUI app by using the Tk C API.

In order to test the API I read this article (https://wiki.tcl-lang.org/page/Adding+Tcl%2FTk+to+a+C+application) and tried to compile the sample
"tk/unix/tkAppInit.c" program from the tk sources.

Unfortunately it didn't work out and I got the Errors as seen down below.
Somehow the linker doesn't seem to find some of the functions necessary.

Have there been some changes to the API I oversaw that also didn't get
fixed in the sample programs? Or did I oversee something else?

############# compiler/linker output ##########################

/usr/bin/ld: /tmp/ccDSowfU.o: in function `main':
tkAppInit.c:(.text+0x1a): undefined reference to `Tcl_FindExecutable'
/usr/bin/ld: tkAppInit.c:(.text+0x1f): undefined reference to `Tcl_CreateInterp'
/usr/bin/ld: tkAppInit.c:(.text+0x3a): undefined reference to `Tk_MainEx'
/usr/bin/ld: /tmp/ccDSowfU.o: in function `Tcl_AppInit':
tkAppInit.c:(.text+0x5a): undefined reference to `Tcl_Init'
/usr/bin/ld: tkAppInit.c:(.text+0x75): undefined reference to `Tk_Init'
/usr/bin/ld: tkAppInit.c:(.text+0x8c): undefined reference to `Tk_SafeInit'
/usr/bin/ld: tkAppInit.c:(.text+0x96): undefined reference to `Tk_Init'
/usr/bin/ld: tkAppInit.c:(.text+0xa5): undefined reference to `Tcl_StaticPackage'
/usr/bin/ld: tkAppInit.c:(.text+0xb6): undefined reference to `Tcl_NewStringObj'
/usr/bin/ld: tkAppInit.c:(.text+0xca): undefined reference to `Tcl_NewStringObj'
/usr/bin/ld: tkAppInit.c:(.text+0xe7): undefined reference to `Tcl_ObjSetVar2'

#########################################################

Christian Gollwitzer

unread,
Sep 15, 2020, 4:16:49 PM9/15/20
to
Am 15.09.20 um 21:22 schrieb lht...@gmail.com:
> Hello,
>
> I'm relatively new to Tcl/Tk and tried to build a GUI app by using the Tk C API.
>
> In order to test the API I read this article (https://wiki.tcl-lang.org/page/Adding+Tcl%2FTk+to+a+C+application) and tried to compile the sample
> "tk/unix/tkAppInit.c" program from the tk sources.
>
> Unfortunately it didn't work out and I got the Errors as seen down below.
> Somehow the linker doesn't seem to find some of the functions necessary.
>
> Have there been some changes to the API I oversaw that also didn't get
> fixed in the sample programs?
No, you simply didn't tell the linker that you wanted to link the Tcl
and Tk library. Try adding "-ltcl8.6 -ltk8.6" to your linker line.


Christian

Lucas H

unread,
Sep 16, 2020, 2:42:15 AM9/16/20
to
> Try adding "-ltcl8.6 -ltk8.6" to your linker line.

Thank you, it works now.
0 new messages