我正在尝试在Windows 10上使用python 2.7安装
pyslalib package并继续获取以下内容:
我尝试运行“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).根据发现
here的说明从python27.dll创建我自己的libpython27.a修复了问题.
原文链接:https://www.f2er.com/windows/372012.htmlTo 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
tolibpython22.a
:
- Download pexport (from here or
07001).- 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:\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.