1
我试图按照痛饮教程,但我卡住了,现在我使用:痛饮教程问题
- 的Python 3.5.1(V3.5.1:37a07cee5969,2015年12月6日, 1点54分25秒)[MSC v.1900 64位(AMD64)]在Win32
- Vs2015 64,微软(R)C/C++优化编译器版19.00.23918针对x64
- SWIG版3.0.10
内容为:
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(<ime);
return ctime(<ime);
}
example.i
%module example
%{
/* Put header files here or function declarations like below */
extern double My_variable;
extern int fact(int n);
extern int my_mod(int x, int y);
extern char *get_time();
%}
extern double My_variable;
extern int fact(int n);
extern int my_mod(int x, int y);
extern char *get_time();
然后我做的:
swig -python example.i
cl /D_USRDLL /D_WINDLL example.c example_wrap.c -Ic:\Python351\include /link /DLL /out:example.pyd /libpath:c:\python351\libs python35.lib
但是当我尝试python -c "import example"
我得到:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: dynamic module does not define module export function (PyInit_example)
问,这是怎么回事,如何解决呢?