use embedded python to build a dll
zephyrwings at hotmail.com
Wed Dec 8 08:30:37 CET 2004
I got a problem using the embedded python. I'll be appreciated if some one
can show me the way.
What i want is,
1.build a dll(test.dll/test.lib) which uses the embedded python, for
example, i want to use the 're' module.
2.build a exe(usedll.exe) which uses that dll.
3.use py2exe to eliminate the dependence of the python environment.
here is the cpp file to build test.dll/test.lib
**query.py is the python script i used. so i import the module 'query'**
#pragma comment(lib, "d:\\\\sdk\\Python23\\libs\\python23.lib")
BOOL APIENTRY DllMain( HANDLE hModule,
__declspec(dllexport) void __stdcall DoIt()
PyObject *pM=PyImport_ImportModuleEx("query", NULL, NULL, NULL);
here is the file to build usedll.exe
#pragma comment(lib, "..\\Release\\test.lib")
__declspec(dllimport) void __stdcall DoIt();
int main(int argc, _TCHAR* argv)
i use setup.py file like this,
from distutils.core import setup
python setup.py py2exe --includes query --packages encodings
and i got a bunch of files.
Then I put usedll.exe test.dll test.lib query.py and all of these files
generated by py2exe in the same directory. I run the usedll.exe, then I got
a run time error 'this application has requested the runtime to terminate it
in an unusual way...'
but if i don't use those files generated by py2exe, i.e. i use the python
environment on my machine, every thing is fine.
I can not figure out where is the problem. Could anyone give me a hint?
More information about the Python-list