我正在尝试安装 pyslalib package在 Windows 10 上使用 python 2.7 并继续获得以下信息:
“collect2.exe:错误:ld 返回了 1 个退出状态”
当我尝试运行“python setup.py install”时出现的消息。我认为这可能是我的 mingw 配置的问题,但我似乎无法找到问题所在。
如果您对此问题有任何帮助,我们将不胜感激。周末的大部分时间我都在为此苦苦挣扎。
谢谢,
输出错误是:
C:\Python27\libs/libpython27.a(dmmes01026.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00281.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00105.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00253.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00227.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:\Python27\libs/libpython27.a(dmmes00712.o):(.idata$7+0x0): more undefined references to `_head_C__build27_cpython_PCBuild_libpython27_a' follow
collect2.exe: error: ld returned 1 exit status
请您参考如下方法:
这看起来像是我最近遇到的一个问题。我认为 Python 附带的 libpython27.a 有问题(我使用的是 2.7.10 版)。根据找到的说明从 python27.dll 创建我自己的 libpython27.a here解决了问题。
To create Python extensions, you need to link against the Python library. Unfortunately, most Python distributions are provided with
Python22.lib, a library in Microsoft Visual C++ format. GCC expects a .a file (libpython22.ato be precise.). Here's how to convertpython22.libtolibpython22.a:
- Download pexport (from here or https://web.archive.org/web/20000829082204/http://starship.python.net/crew/kernr/mingw32/pexports-0.42h.zip).
- Get
Python22.dll(it should be somewhere on your harddrive).- Run :
pexports python22.dll > python22.defThis will extract all symbols frompython22.dlland write them intopython22.def.- Run :
dlltool --dllname python22.dll --def python22.def --output-lib libpython22.aThis will createlibpython22.a(dlltoolis part of MinGW utilities).- Copy
libpython22.atoc:\python22\libs\(in the same directory aspython22.lib).This trick should work for all Python versions, including future releases of Python. You can also use this trick to convert other libraries.
