Python论坛  - 讨论区

标题:[python-chinese] 怎样修改Python默认调用的C++编译

2005年09月15日 星期四 10:52

Li Weigang dimens at gmail.com
Thu Sep 15 10:52:16 HKT 2005

大家好,
 在用Python调用C++模块时,Python默认的是VC7.1编译器,我想修改为VC6,不知道怎么修改,谢谢。

-- 

Best Wishes
Dimension LEE
dimens at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20050915/02792771/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年09月15日 星期四 11:00

张骏 zhangj at foreseen-info.com
Thu Sep 15 11:00:32 HKT 2005

用vc6自己编译python24的源码
PS: 为什么要换编译器,VC71有免费的命令行版本
----------------------- Original Message -----------------------
From:    Li Weigang <dimens at gmail.com>
To:      python-chinese at lists.python.cn
Date:    Thu, 15 Sep 2005 10:52:16 +0800
Subject: [python-chinese] 怎样修改Python默认调用的C++编译器
----------------------------------------------------------------
> 大家好,
>  在用Python调用C++模块时,Python默认的是VC7.1编译器,我想修改为VC6,不知道怎么修改,谢谢。
> 
> -- 
> 
> Best Wishes
> Dimension LEE
> dimens at gmail.com

--------------------- Original Message Ends --------------------


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年09月15日 星期四 15:48

yangfreecode yangfreecode at sohu.com
Thu Sep 15 15:48:37 HKT 2005

采用ming C编译,将ming/bin加入path
(注:pythonxx.dll一般在winnt/system32下,以下操作后文件如xx.def,xx.a放到python/libs下)

	1)pexports python24.dll >python24.def
	
	2)dlltool --dllname python24.dll --def python24.def --output-lib libpython24.a

-----------------------------------------------------------------------------------------
	The resulting library has to be placed in the same directory as python24.lib. 
	(Should be the libs directory under your Python installation directory.)
	If your extension uses other libraries (zlib,...) you might have to convert them too. 
	The converted files have to reside in the same directories as the normal libraries do.
	To let Distutils compile your extension with Cygwin you now have to type
	python setup.py build --compiler=cygwin
	and for Cygwin in no-cygwin mode3 or for MinGW type:
	python setup.py build --compiler=mingw32
-----------------------------------------------------------------------------------------

   3)找到msvccompiler.py 一般在Python/Lib/distutils 下,找到以下语句,并删除

	if len (self.__paths) == 0:
    	raise DistutilsPlatformError, ("Python was built with version %s of Visual Studio, "
              "and extensions need to be built with the same "
              "version of the compiler, but it isn't installed." % self.__version)
              
   4)Creating an extension with Distutils
	You must specify which compiler to use, so you would do:
	
		python setup.py build --compiler=mingw32
	
	and then:
	
		python setup.py install

	具体参看:http://www.mingw.org/MinGWiki/index.php/Python%20extensions



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号