Help: trying to create python wrapper for cdk using swig

dubal at my-deja.com dubal at my-deja.com
Mon Jan 8 08:12:40 EST 2001


Hello good folks!

We are trying to build a business application that needs a database
front end to be done for dumb/text/character terminals. The database of
our choice is Postgresql, language Python, os Redhat 6.2 or 7.0 on
Intel hardware. We looked at newt, ncurses/pyncurses and
http://www.vexus.ca/CDK.html. Of these we like cdk best because it has
readymade widgets such as "matrix" which is just what we need to
display things such as invoices on dumb terminals with scrolling arrays.

How can we use cdk from within python? We went to swig. While swig is
able to wrap the example routine given in the documentation, it is not
able to create wrapper correctly for any of cdk's routines. For example
we take a routine called label.c and created label.i for it thus:

%module label
%{
#include <cdk/cdk.h>
#include <cdk/label.h>
%}
%include "cdk/cdk.h"
%include "cdk/label.h"

then we run swig thus:

swig -python -shadow -I/usr/include -I/usr/local/include -make_default -
DNCUSRSES label.i

(cdk is installed by default into /usr/local/include/cdk
and /usr/local/lib)
Above swig command does not give any error. Produces label.py and
label_wrap.c as expected.

Then we compile thus:
gcc -fPIC -g -O2 -I/usr/include/python1.5 -I/usr/local/include -
DHAVE_CONFIG_H -c ./label_wrap.c
gcc -shared label_wrap.o -o labelcmodule.so
These also do not produce any errors.

Then we test our wrapper by importing label into python. This produces
the following error:
ImportError: ./labelcmodule.so: undefined symbol: CDKDEBUG

The same error appears for other cdk widget files such as entry.c as
well.

What are we doing wrong? CDKDEBUG is defined in cdk.h as
extern  FILE	*CDKDEBUG;
We even tried to define the same in label.i in place of the header
files thus:

%module label
%{
#include <cdk/cdk.h>
#include <cdk/label.h>
%}
extern  FILE    *CDKDEBUG;

This produced the same error.

We are not very familiar with c. Please help.
Thanks in advance.
Dubal


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list