Swig-Python problems

Joe Mason joe at notcharles.ca
Mon Mar 15 23:54:34 CET 2004

In article <cdb8761d.0403150739.5de0fee4 at posting.google.com>, matteo wrote:
> Hi, I've got a problem with SWIG and Python2.2.I've installed the
> SWIG1.3.21 releaseunder QNX6.2 platform .I tried to make the exemple
> example.c (in the directory ../Swig/Exemple/python/simple)
> /* File : example.c */
>  #include <time.h>
>  double My_variable = 3.0;
>  int fact(int n) {
>      if (n <= 1) return 1;
>      else return n*fact(n-1);
>  }
>  int my_mod(int x, int y) {
>      return (x%y);
>  }
>  char *get_time()
>  {
>      time_t ltime;
>      time(&ltime);
>      return ctime(&ltime);
>  }.
> After the commans:
>  swig -python example.i
>  gcc -c example.c example_wrap.c -I/usr/local/python2.2
>  ld -shared example.o example_wrap.o -o _example.so 
>  I use Python module as follows
> >>> import example
> and I've got the message: "Memory falut (core dumped)"
> What can I do??

I've found on Linux that it's easy to run the entire Python interpreter
under a debugger.  I'm not familiar with the tools on QNX, but I would
add "-g" to the gcc line (to add debugging symbols), and then run "gdb
python", so that when the program crashes you can see exactly where.

(If you're not familiar with gdb, type "run" at the first prompt, and
then use the interpreter as normal, and when the crash happens and you
get back to the gdb prompt, type "bt" to get a backtrace.  This should
be all you need to get started.)


More information about the Python-list mailing list