問(wèn)題描述
我正在嘗試在 Windows 10 上使用 python 2.7 安裝 pyslalib 包,并不斷收到以下信息:
I'm trying to install the pyslalib package using python 2.7 on Windows 10 and keep getting the following:
collect2.exe:錯(cuò)誤:ld 返回 1 個(gè)退出狀態(tài)"
"collect2.exe: error: ld returned 1 exit status"
當(dāng)我嘗試運(yùn)行python setup.py install"時(shí)的消息.我認(rèn)為這可能是我的 mingw 配置的問(wèn)題,但我似乎無(wú)法找到問(wèn)題所在.
message when I try to run "python setup.py install". I think this might be an issue with my mingw configuration, but I can't seem to locate the problem.
對(duì)于這個(gè)問(wèn)題的任何幫助將不勝感激.我周末大部分時(shí)間都在為此苦苦掙扎.
Any help with this issue would be greatly appreciated. I've eaten up most of the weekend struggling with this.
謝謝,
輸出錯(cuò)誤是:
C:Python27libs/libpython27.a(dmmes01026.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:Python27libs/libpython27.a(dmmes00281.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:Python27libs/libpython27.a(dmmes00105.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:Python27libs/libpython27.a(dmmes00253.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:Python27libs/libpython27.a(dmmes00227.o):(.idata$7+0x0): undefined reference to `_head_C__build27_cpython_PCBuild_libpython27_a'
C:Python27libs/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
推薦答案
這好像是我最近遇到的一個(gè)問(wèn)題.我認(rèn)為 Python 附帶的 libpython27.a
存在問(wèn)題(我使用的是 2.7.10 版).根據(jù) python27.dll 創(chuàng)建我自己的 libpython27.a
="nofollow">這里解決了這個(gè)問(wèn)題.
This looks like a problem I had recently. I think there is a problem with the libpython27.a
that comes included with Python (I'm on version 2.7.10). Creating my own libpython27.a
from the python27.dll
as per the instructions found here fixed the problem.
要?jiǎng)?chuàng)建 Python 擴(kuò)展,您需要鏈接到 Python圖書(shū)館.不幸的是,大多數(shù) Python 發(fā)行版都提供了Python22.lib
,Microsoft Visual C++ 格式的庫(kù).海合會(huì)期望一個(gè).a 文件(準(zhǔn)確地說(shuō)是 libpython22.a
.).以下是轉(zhuǎn)換方法python22.lib
到 libpython22.a
:
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 convertpython22.lib
tolibpython22.a
:
- 下載 pexport(從這里或https://web.archive.org/web/20000829082204/http://starship.python.net/crew/kernr/mingw32/pexports-0.42h.zip).
- 獲取
Python22.dll
(它應(yīng)該在你硬盤的某個(gè)地方). - 運(yùn)行:
pexports python22.dll >python22.def
這將提取所有符號(hào)從python22.dll
并將它們寫(xiě)入python22.def
. - 運(yùn)行:
dlltool --dllname python22.dll --def python22.def --output-lib libpython22.a
這將創(chuàng)建libpython22.a
(dlltool
是 MinGW 實(shí)用程序的一部分). - 將
libpython22.a
復(fù)制到c:python22libs
(與python22.lib
).
- 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.def
This will extract all symbols frompython22.dll
and write them intopython22.def
. - Run :
dlltool --dllname python22.dll --def python22.def --output-lib libpython22.a
This will createlibpython22.a
(dlltool
is part of MinGW utilities). - Copy
libpython22.a
toc:python22libs
(in the same directory aspython22.lib
).
這個(gè)技巧應(yīng)該適用于所有 Python 版本,包括 Python 的未來(lái)版本.你也可以使用這個(gè)技巧轉(zhuǎn)換其他庫(kù).
This trick should work for all Python versions, including future releases of Python. You can also use this trick to convert other libraries.
這篇關(guān)于無(wú)法在 Windows 10 上使用 python2.7/MINGW 安裝 pyslalib 包的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!