[Pythonmac-SIG] Writting C extension in Mac os X tiger

Zhi Peng zhiyong_peng2003 at yahoo.com
Thu Oct 27 22:41:20 CEST 2005


I would like to run this code from Mac 10.4 environment first as individual program by create main and put some Py_Initialize();
 
and Py_Finalize() 
 
inside main and compile it. If it can run, it should be able to compiled as .so library. 
 
 
Regards 
 
Zhi 

Jaonary Rabarisoa <jaonary at free.fr> wrote:
Hi all,


I'm trying to write a C++ function that I can use with python. The 
sample code below works well under windows and linux but not under 
mac os x tiger :


#include "Python.h"

static PyObject * mHarrisDetector(PyObject *self, PyObject *args)
{

//Parse the args
const int N = 5;
const float eta = sqrt(2.f);
const float sigma_0 = 1.f;
const char* img_file;

int ok = PyArg_ParseTuple(args, "s|ffi", &img_file, &sigma_0, 
&eta,&N);

printf("%s %f %f %d \n",img_file,sigma_0,eta,N);

Py_INCREF(Py_None);
return Py_None;
}

static PyMethodDef PyIFFD_methods[] = {
{"mHarrisDetector",
mHarrisDetector,
METH_VARARGS,
"mHarrisDetector(image,sigma 0,eta,N) -> Array of Harris Point"},

{NULL, NULL}
};

extern "C"
void initPyIFFD(void)
{
Py_InitModule("PyIFFD", PyIFFD_methods);
}



To build this code I created a BDS dynamic library with Xcode. While 
loading the module I get this error :

>>> import PyIFFD
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap


So what I've missed ?

Thanks a lot for your help.


Jaonary Rabarisoa
jaonary at free.fr


_______________________________________________
Pythonmac-SIG maillist - Pythonmac-SIG at python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

		
---------------------------------
 Yahoo! FareChase - Search multiple travel sites in one click.  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051027/2ccf3ec8/attachment.htm


More information about the Pythonmac-SIG mailing list