Python – How to link (C++) with renamed Python .lib and .dll

cdlllinkerpython

When I include "Python.h" from Python 2.5 in a C++ project, it knows through some magical process that it has to link with "python25.lib" and load "python25.dll" at runtime, though I didn't specified anything neither in "Linker -> Additional Dependencies" nor in "Linker -> Additional Library Directories".

Now I would like to rename python25.lib/.dll to something like gpython25.lib/.dll and link with them. This is to be sure to link with THIS python dll and not another python25.dll from another installed application, independently from the PATH search order.

Is there a way to do that?

Thanks
-David

Best Answer

MSVC supports this feature through pragmas:

#pragma comment(lib, "python25.lib");

More info in MSDN.

Look into Python.h file and modify the name of the linkage, if that what you want.