Why can’t I build python extensions with a different version of Visual Studio?

The short answer: you probably can if you are careful enough to limit your use of Python API calls.

For example, you cannot use PyFile_AsFile, the reason is that C runtime objects like FILE* created in one runtime e.g. msvcrt.dll cannot be used in another, e.g. msvcrt70.dll

In addition, malloc() allocated memory from one runtime cannot be freed from another runtime.

Here’s a rundown:

Interestingly, there are techniques called forwarder DLLs that redirect DLL calls to another version.

More interestingly though is the possibility of using Visual Studio to link against the older runtime directly


About this entry