2015-09-13 88 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日發佈)中解決了,所以現在最簡單的解決方案就是更新。 –