Recently, I build a hybrid system with C++ and python.
First,I encapsulate a class(I can't guarantee the robustness of this
class ) with boost.python which can implement some functions that can not
be implemented by C++, I get a .pyd File in result.
Second,I embed a python interpreter in c++.
Third, use the embed interpreter to execute a .py File.The .py File
include the module that in .pyd File I created.
Here, the problem comes out! When I start my main project. I can only
debug the problems in my main project, when my main project use the python
interpreter to execute the python interpreter, I can't see what happened in
my pyd File, the whole project collapsed.I know the error is in the pyd
File, and if I set a break point in my resource files of pyd File, either
the project will go to the break point.
Is there any methods to debug the resource file in this condition!
the codes to create *pyd File*
execute.h
[code=c]#include <string>
class Excute
{
public:
Excute(){}
int getIoReuslt(std::string ioStr);
int getSignal();
};
#endif [/code]
execute.cpp
[code=c]int Excute::getIoReuslt(std::string ioStr)
{
//do something here
return 1;
}
int Excute::getSignal()
{
int i = rand()%2;
return i;
}
BOOST_PYTHON_MODULE(pythonDll)
{
using namespace boost::python;
class_<Excute>("Excute", init<>())
.def("getIoResult", &Excute::getIoReuslt)
.def("getSignal", &Excute::getSignal)
;
} [/code]
the codes in test.py:
[code=python]from pythonDll import*
h=Excute()
h.excute("abc")
print h.getSignal()
...[/code]
The codes to embed python Interpreter:
[code=c]int main(int argc, char* argv[])
{
Py_Initialize();
FILE * fp = fopen("$PATH/test.py", "r");
if (fp == NULL)
{
return 1;
}
PyRun_SimpleString("execfile($PATH/test.py')");
Py_Finalize();
system("Pause");
return 0;
} [/code]
How to debug pyd File while I start the python Interpreter!
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.