Giuseppe Ottaviano
Giuseppe Ottaviano

Reputation: 4633

Compiling Python extensions with VC2010

I have some code written in C++0x that I want to expose to Python 2.7 as an extension.

Since it uses several C++0x features I'd prefer not to rewrite it in C++03, so I'm forced to use VC2010. However the default Python 2.7 installation is compiled with VC2008.

I found this post that explains how to force distutils to use VC2010, but a commenter points out that this will result in a DLL clash between msvcr90.dll (linked by the interpreter) and msvcr100.dll (linked by the extension).

Is there a way to compile the extension in VC2010 without having to recompile Python?

(I've started programming on Windows only recently, so I don't have an exact understanding of how dynamic linking works there)

Upvotes: 0

Views: 475

Answers (1)

Idan K
Idan K

Reputation: 20881

No, there isn't.

Like you already figured out, when you compile something with the VS2010 toolset, it links with msvcr100.dll. Since Python links with msvcr90.dll, you will get unpleasant surprises when mixing those in the same application.

Your best option for now is to probably stop using any C++0x features and compile your extension with VS2008 or mingw.

If this is something you do not intend on distributing and it's for playing around only, compiling Python using VS2010 is the only option.

Upvotes: 2

Related Questions