2015-09-13 61 views
1

我试图使用python 2.7在Windows 10安装pyslalib package和不断收到以下内容:无法使用python2.7/MINGW在Windows上安装pyslalib包10

“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 

回答

5

这看起来像一个问题,我最近有。我认为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.a to be precise.). Here's how to convert python22.lib to libpython22.a :

  1. Download pexport (from here or https://web.archive.org/web/20000829082204/http://starship.python.net/crew/kernr/mingw32/pexports-0.42h.zip).
  2. Get Python22.dll (it should be somewhere on your harddrive).
  3. Run : pexports python22.dll > python22.def This will extract all symbols from python22.dll and write them into python22.def .
  4. Run : dlltool --dllname python22.dll --def python22.def --output-lib libpython22.a This will create libpython22.a (dlltool is part of MinGW utilities).
  5. Copy libpython22.a to c:\python22\libs\ (in the same directory as python22.lib).

This trick should work for all Python versions, including future releases of Python. You can also use this trick to convert other libraries.

+0

我有同样的问题,你的小费帮助我解决了我的问题。 – alex

+0

该链接处于离线状态,archive.org有一个副本:https://web.archive.org/web/20000829082204/http://starship.python.net/crew/kernr/mingw32/pexports-0.42h.zip编辑 – n611x007

+1

这个问题似乎已经在Python 2.7.11(12月5日发布)中解决了,所以现在最简单的解决方案就是更新。 –