且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法在 Windows 10 上使用 python2.7/MINGW 安装 pyslalib 包

更新时间:2022-11-26 10:40:09

这好像是我最近遇到的一个问题.我认为 Python 附带的 libpython27.a 存在问题(我使用的是 2.7.10 版).根据 python27.dll 创建我自己的 libpython27.a="nofollow">这里解决了这个问题.

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.

要创建 Python 扩展,您需要链接到 Python图书馆.不幸的是,大多数 Python 发行版都提供了Python22.lib,Microsoft Visual C++ 格式的库.海合会期望一个.a 文件(准确地说是 libpython22.a.).以下是转换方法python22.liblibpython22.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 convert python22.lib to libpython22.a:

  1. 下载 pexport(从这里或https://web.archive.org/web/20000829082204/http://starship.python.net/crew/kernr/mingw32/pexports-0.42h.zip).
  2. 获取Python22.dll(它应该在你硬盘的某个地方).
  3. 运行:pexports python22.dll >python22.def 这将提取所有符号从 python22.dll 并将它们写入 python22.def.
  4. 运行:dlltool --dllname python22.dll --def python22.def --output-lib libpython22.a 这将创建 libpython22.a (dlltool 是 MinGW 实用程序的一部分).
  5. libpython22.a 复制到 c:python22libs (与python22.lib).
  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:python22libs (in the same directory as python22.lib).

这个技巧应该适用于所有 Python 版本,包括 Python 的未来版本.你也可以使用这个技巧转换其他库.

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