how: embed + extend to control my running app?

Dave Angel davea at davea.name
Thu Jul 25 03:14:34 CEST 2013


On 07/24/2013 08:51 PM, David M. Cotter wrote:
> update: okay so the python27.dll is in /windows/system32 so ignore that
>
> i've set my include directory correct, so i can compile
>
> i've set my "additional libraries" directory to the "libs" directory (where the ".lib" files are.  (note: NOT including "Lib" directory, cuz that's full of .py files and folders) (note: NOT including "DLLs" directory, cuz, why would i?)
>
> No need to specify "additional dependencies" for the .lib file, cuz the pyconfig.h file does that.
>
> but there is no "python27_d.dll" anywhere to be found, so i hacked pyconfig.h to get rid of the "_d".
>
> so it all compiles.
>
> but it won't link:
>
> 	LNK2001: unresolved external symbol __imp___Py_RefTotal
> 	LNK2001: unresolved external symbol __imp___Py_NoneStruct
> 	LNK2019: unresolved external symbol __imp__PyArg_ParseTuple
> 	LNK2019: unresolved external symbol __imp__PyFloat_FromDouble
> 	LNK2019: unresolved external symbol __imp__PyString_FromString
> 	LNK2019: unresolved external symbol __imp__PyRun_SimpleStringFlags
> 	LNK2019: unresolved external symbol __imp__Py_InitModule4TraceRefs
> 	LNK2019: unresolved external symbol __imp__Py_Initialize
> 	LNK2019: unresolved external symbol __imp__Py_SetProgramName
> 	LNK2019: unresolved external symbol __imp__Py_Finalize
> 	LNK2019: unresolved external symbol __imp__PyRun_SimpleFileExFlags
>
> what, pray tell, am i doing wrong?  *hopeful face*
>

Digging *far* back in my Windows memory, those look like imports.  You 
probably need the import lib for the Python.dll.  Probably called 
somethng like python.lib.   You could check that by doing a dumpbin of 
python.dll and searching for those entry points.

An import lib in Windows simply tells the linker that those symbols will 
be resolved at runtime, and from a particular dll. They can also change 
the names to be used (removing the __imp__ prefix) and even specify a 
numeric entry point (to slow down people who reverse engineer these things).

If I recall right, there's a way in Microsoft's toolset to create an 
import lib from a dll, assuming the dll doesn't restrict itself to those 
numeric thingies.

As for the _d suffix, that's commonly used to specify debug versions of 
things.  They would have extra symbol information, and less optimized 
code so that it's easier to use a debugger on them.


-- 
DaveA




More information about the Python-list mailing list