我已经使用cygwin中的gcc将几个.c程序编译到相应的.o文件中,如下所示:
gcc -fPIC -c test5*.c -I/usr/include/python2.7 -L/usr/lib/python2.7 -lpython2.7
现在,我正在尝试将它们链接到可以由python使用的DLL库中。这是问题的开始,首先,我尝试了以下命令:
gcc -shared test5*.o -o test5.dll -I/usr/include/python2.7 -L/usr/lib/python2.7
然后,它抱怨没有找到很多python函数调用,如下面所示:
test5_wrap.o:test5_wrap.c:(.text+0x42e0): undefined reference to `PyArg_ParseTuple'
test5_wrap.o:test5_wrap.c:(.text+0x450e): undefined reference to `PyArg_ParseTuple'
test5_wrap.o:test5_wrap.c:(.text+0x4924): undefined reference to `PyString_FromString'
test5_wrap.o:test5_wrap.c:(.text+0x4942): undefined reference to `PyString_FromString'
test5_wrap.o:test5_wrap.c:(.text+0x4963): undefined reference to `PyString_FromString'
test5_wrap.o:test5_wrap.c:(.text+0x4972): undefined reference to `PyString_ConcatAndDel'
所以,据大家说,这是因为需要指定-lpython2.7,所以我将它添加到gcc命令中,如下所示:
gcc -shared test5*.o -o test5.dll -I/usr/include/python2.7 -L/usr/lib/python2.7 -lpython2.7
但现在,它抱怨找不到-lpython2.7:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lpython2.7
collect2: error: ld returned 1 exit status
任何帮助都将不胜感激。