Yet another Numeric Swig core dump problem
Edward C. Jones
edcjones at erols.com
Thu Aug 9 19:48:16 EDT 2001
The following Python / SWIG / Numeric program dumps core. I use RedHat Linux
on a PC. Python 2.1, Numeric 20.0.0, SWIG 1.1 build 883, gcc 2.96.
The output looks like:
> testdb.py
called import_array
L11
Segmentation fault (core dumped)
>KLTfeatures.KLTSelectGoodFeatures()
>
The program files are:
-----------
testdb.py:
#! /usr/bin/python
import Numeric, KLTfeatures
KLTfeatures.KLTSelectGoodFeatures()
-----------
KLTfeatures.h:
#include "Python.h"
#include "/usr/include/python2.1/Numeric/arrayobject.h"
void KLTSelectGoodFeatures(void);
-----------
KLTfeatures.i:
%module KLTfeatures
%{
#include "KLTfeatures.h"
%}
%init %{
import_array();
printf("called import_array\n");
%}
void KLTSelectGoodFeatures(void);
-----------
KLTfeaturesmodule.c:
#include "KLTfeatures.h"
void KLTSelectGoodFeatures()
{ PyArrayObject *pao;
int dims[2];
dims[0] = 100;
dims[1] = 200;
printf("L11\n");
pao = (PyArrayObject*) PyArray_FromDims(2, dims, PyArray_UBYTE);
printf("L17\n");
Py_DECREF(pao);
}
----------
How to compile:
swig -python KLTfeatures.i
gcc -c -Wall KLTfeaturesmodule.c KLTfeatures_wrap.c -I/usr/include/python2.1
ld -shared KLTfeaturesmodule.o KLTfeatures_wrap.o -o KLTfeatures.so
More information about the Python-list
mailing list