CPython sources - how to build a STATIC python26.lib?

南笙酒味 提交于 2019-12-05 10:03:44

I've been building Python static from 2.4 through to 2.7, and it does take a bit of work to set up.

You do need to update the configuration for all enabled projects in the solution, setting them to /MT. To build Python static, everything that it references - including libraries like SQLite or OpenSSL - must also be static. This is true even of the .pyd modules, which aren't actually included, since otherwise they won't be importable later.

You may also need to make this edit near the top of Modules/socketmodule.h:

#else /* MS_WINDOWS */
# define inet_pton _msvc_inet_pton
# define inet_ntop _msvc_inet_ntop
# include <winsock2.h>
# include <ws2tcpip.h>
# include <wspiapi.h>
# undef inet_pton
# undef inet_ntop

Once you get beyond the immediate error, some other things that are probably necessary:

  • Disable creation of embedded manifests; see line ~650 in distutils msvc9compiler.py; the fact that it creates these even when building with /MT is a bug.

  • Change /MD to /MT in distutils msvccompiler/msvc9compiler.py, since otherwise thirdparty libs won't build correctly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!