Python 2.6 and wrapping C libraries on Windows

L. Lindstrom spam-trap at telus.net
Wed Apr 30 21:23:06 EDT 2008


Christian Heimes wrote:
> L. Lindstrom schrieb:
>> I have read that Python extension modules must link to the same C
>> run-time as the Python interpreter. This I can appreciate. But does this
>> requirement extend to the C libraries an extension module wraps. The
>> case in point is Pygame and SDL. The Pygame extension modules are built
>> with distutils, so for Python 2.6 using Visual Studio 2008 should ensure
>> the .pyd files link to msvcr90.dll. But SDL is built using Msys/MinGW
>> and the configure/make tool chain. This fails when linking to
>> msvcr90.dll since the small test programs configure builds lack manifest
>> files. They fail to load msvcr90.dll, raising an R6034 error instead. So
>> besides heap management and FILE pointers, is there any reason SDL, or
>> any C dependency, needs to link to the same C run-time as Python? If I
>> ensure SDL frees memory it allocates and does not directly access a file
>> opened by Python can I just use another C run-time such as msvcrt?
>>
> 
> Your analysis of the problem and the implication of mixing CRTs is
> correct. However ...
> 
> It should be trivial to modify the build systemof SDL so that the
> manifest is integrated into the DLLs. Everything else is a hack. It
> *should* work and in reality it *does* work for most cases. But someday
> you'll hit a solid wall and get strange and hard to debug segfaults.
> 
> It's in your own interest to get it right in the first place. And you'd
> serve the Python community greatly by providing a nice tutorial how to
> modify 3rd party builds. *hint* :)
> 
> If you need any help feel free to contact me. The new build system is
> mostly my work with help from Martin, Amaury and other core developers.
> 
> Christian
> 
Linking to msvcr90.dll is possible with MinGW. The problem is with the 
configure scripts. So I can run configure against msvcrt.dll, then 
switch to mscvr90.dll for make. If this works I will make SDL and a test 
program available on-line so someone can find the appropriate manifests.


-- 
Lenard Lindstrom
"%s@%s.%s" % ('len-l', 'telus', 'net')



More information about the Python-list mailing list