Python extensions in C... and stdout problems!

piet at cs.uu.nl piet at cs.uu.nl
Mon Aug 14 05:34:34 EDT 2000


>>>>> Victor B. Putz <vputz at nyx.net> (VBP) writes:

VBP> Ran into an irritating problem with gcc 2.95, Python 1.5.2, and building a
VBP> shared-module extension module in C.

VBP> The essence of the problem is that any C function which references
VBP> stdout (and I assume stdin or stderr) crashes the program and
VBP> interpreter immediately. 
....
VBP> I'm using the distributed "Makefile.pre.in" to make the module, and
VBP> without the reference to stdout, it works like a champ--with it, it's
VBP> a no go. I can't figure out if Python isn't initializing the stdout
VBP> family on startup, if there's something wrong with the way the shared
VBP> module is being created, or what. If anyone has ANY ideas, I'd really
VBP> appreciate some help.

You must use exactly the same stdio implementation in your extension module
as the python interpreter, which is the one in msvcrt.dll (I think).
If you link with anything else, e.g. crtdll or cygwin, you are lost.
So use a compiler that uses the header files of, and links with msvcrt.dll.
E.g. the msvcrt.dll version of mingw32. Cygwin has an option -mnocygwin,
but I think this uses crtdll. Maybe it can be configured to use msvcrt.dll
but I haven't found anything.

So I guess compiling with mingw32(msvcrt version) is the best option.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl



More information about the Python-list mailing list