Trouble Importing Tkinter in embedded C program

Rick Olson r_olson at sandiego.edu
Wed Nov 19 15:51:10 EST 2003


David Boddie <davidb at dcs.st-and.ac.uk> wrote in message news:<bpe51c$odr$1 at hercules.btinternet.com>...
> > Can someone guide me in the right direction to allow calls to Tkinter
> > through the embedded python?  I know there are ways of using Tk/Tcl
> > through C, but I'm not familiar enough with Tk/Tcl to try that.
> 
> If you are able to change the conditions under which the C program is
> built (paths, libraries, etc.) then you may want to link against the
> _tkinter.so library in the /usr/lib/python2.2/lib-dynload directory.
> 
> That's just a guess, however. Maybe this is answered in an FAQ somewhere.

Thanks for the suggestion.

I tried to check the FAQ and newsgroup, but was unsuccessful.  I may
well have missed it.  I'm not a serious programmer and am frequently
unclear on exactly how to compile, link...

Nevertheless, I tried linking _tkinter.so by changing the makefile a
few different ways all of which amount to the makefile below.  FWIW if
I drop the definition of DLL this makefile will compile and run the
examples in Extending and Embedding the Python Interpreter.

Thanks again--
Rick



CC = gcc

PY = /usr/include/python2.2
PYLIB = /usr/lib/python2.2/config/libpython2.2.a
PYINC = -I/usr/include/python2.2 -I/usr/include

# Compiler flags
OPT=		-g
CFLAGS=	$(OPT)

LIBS=	-L/usr/lib \
	-L/usr/X11R6/lib \
	-ltk8.4 -ltcl8.4 -lnsl -lX11 -ldl -lreadline -lieee -lpthread -lutil
LDFLAGS=-Xlinker -export-dynamic
SYSLIBS=-lm
DLLS=	/usr/lib/python2.2/lib-dynload/-tkinter.so
ALLLIBS=$(PYLIB) $(LIBS) $(SYSLIBS)

testtk:	testtk.o
	$(CC) $(LDFLAGS) testtk.o $(DLLS) $(ALLLIBS) $(OPT) -o testtk

testtk.o:	testtk.c
	$(CC) testtk.c -c $(OPT) $(PYINC)




More information about the Python-list mailing list