[英]LoadLibrary python with dll write in c++
I have write a python script that load a dll writed in c++ . 我已经写了一个python脚本,可以加载用c ++编写的dll。
Script is : 脚本是:
from ctypes import *
mydll = cdll.LoadLibrary('C:\\Users\\gpiscite\\Documents\\Project\\DllXPython\\Debug\\DllXPython.dll')
mydll
mydll.fnDllXPython(956, c_char_p("c_char_p"), c_void_p(0), "std::string")
The c++ code is compiled in VisualStudio as a DLL and it is: C ++代码在VisualStudio中编译为DLL,它是:
// DllXPython.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include <cstdlib>
#include <string>
#include "DllXPython.h"
// This is an example of an exported variable
DLLXPYTHON_API int nDllXPython=0;
// This is an example of an exported function.
DLLXPYTHON_API int fnDllXPython(int aInt, char* apChar, void* apVoid, std::string aString)
//DLLXPYTHON_API PyObject * fnDllXPython(PyObject *self, PyObject *args)
{
return 0;
}
I had attached debug on python process and i saw thad the exception was raised on return 0 execution . 我已经在python进程上附加了debug,但是我看到在执行return 0时引发了异常。 The exception raised is:
引发的异常是:
Debug Assertion Failed! 调试断言失败! ..... _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) ....
..... _BLOCK_TYPE_IS_VALID(pHead-> nBlockUse)....
Any idea ? 任何想法 ? Thanks.
谢谢。
"std::string" is not a std::string. “ std :: string”不是std :: string。 It is merely a char*
它只是一个字符*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.