WindowsXP development using msvc .net 2003
Scott David Daniels
scott.daniels at acm.org
Wed Dec 7 13:43:52 EST 2005
Michael O'Brien wrote:
> Hola~
>
> I'm developing a c++ library that contains python types and methods on
> Windows using MSVC .net 2003 and g++ on Linux.
>
> .... On Windows, it seems like you have to compile a custom version of
> python and then compile my plugin against the debug version of python.
> Is that right?
Nope.
> I guess I don't understand why the Windows distribution
> of Python includes the headers and libraries if only an optimized
> plugin could access it.
You do need compatible C/C++ libraries for both Python and your module.
Microsoft feels free to change calling conventions and layouts of
some essential data structures (such as the thing pointed to by a FILE*)
between releases of their C/C++ compilers, and depending upon whether
the debug flag is on. On Linux, I'm sure you could buy an exotic C/C++
system from some vendor that produces hyper-optimizing code that would
not mesh well with the pre-built Python. The issue you see is a C/C++
compiler issue.
> I've compiled my own version of Python (it
> worked out of the box), but I wouldn't think I would need to.
You don't need to.
> Now, I'd like to update my plugin to be able to export a Numeric array
> type. On Linux, I just point the compiler at the headers, and it all
> seems to work. On Windows, do I have to compile a debug version of
> Numeric to do so?
If you are not using a compatible compiler w/ flags, then yes.
> I feel like I'm making things harder than they need to be on Windows.
> Any advice on building Python modules on both Windows and Linux would
> be appreciated.
It does matter which version of python you are discussing -- 2.4
switched from VC 6.0 as the compiler to VC 7.1 (the .net 2003 compiler).
If you are working with 2.3.* or earlier you _will_ need to recompile.
If you are working with 2.4.* or later, your compiler will work, but
it may not work if you turn on debugging.
You might take a look at the vrplumber page, that may help:
http://www.vrplumber.com/programming/mstoolkit
I also have some code to "monkey patch" distutils (change at runtime
without having to alter any source code) if distutils seems to
be the problem.
--Scott David Daniels
scott.daniels at acm.org
More information about the Python-list
mailing list