Python扩展,我哪里出错了

全部,
我正在尝试创建一个扩展模块并继续遇到错误,
"/usr/local/lib/python2.5/site-packages/mytest.so:不确定的符号:
pyinitmodule"
提前致谢,
*这是我的源代码和设置.
*/ *mytest.c */
#include
#include
#include
#include
静态pyObject *errorObject;
静态char iseven__doc __ [] ="确定数字是奇数还是
甚至\ n";
静态pyObject *iseven(pyObject *self,pyobject *args){
int InputValue;
int returnValue;
如果(!pyarg_parsetuple(args," i"和inputValue)){
pyerr_setstring(pyexc_valueerror,"参数解析错误");
返回null;
}
if(0 == inputValue%2){
returnValue = 1;
} 别的 {
returnValue = 0;
}
返回py_buildvalue(" i",returnValue);
}
静态char getfactorial__doc __ [] ="此模块将一个数字作为一个
范围 \
并返回该数字\ n"的阶乘;
静态pyObject *getFactorial(pyObject *self,pyobject *args){
int InputValue;
int结果值;
如果(!pyarg_parsetuple(args," i"和inputValue)){
pyerr_setstring(pyexc_valueerror,"参数解析错误");
返回null;
}
resultValue = fortorialHelper(inputValue);
返回pyint_fromlong(结果值);
}
int fortorialhelper(int factor){
if(因子<= 0){
返回0;
}
if(因子== 1){
返回1;
}
返回因子*fortorialHelper(因子1);
}
静态结构pymethoddef mytest_methods [] = {
{" iseven",iseven,meth_varargs,"确定一个数字的奇数",
{" getFactorial",getFactorial,meth_varargs,"计算阶乘
数字的值"},
{null,null,0,null}
};
void initmytest(){
pyObject *m, *d;
m = pyinitmodule(" mytest",mytest_methods);
d = pymodule_getDict(m);
ERROROBJECT = PYBUILDVALUE(" S"," MyTest模块错误");
PYDICT_SETITEMSTRING(D,"错误",errorObject);
if(pyerr_occurred())
py_fatalerror("不能初始化模块mytest!");
}
*我的setup.py代码:*
#!/usr/bin/env Python
来自Distutils.Core Import Setup,扩展
设置(name =" mytest",版本=" 1.0",
ext_modules = [Extension(" mytest",[" mytest.c"])))

标签: python

添加新评论