0
我寫了一個python腳本加載dll在C++中編寫。LoadLibrary python與dll寫在c + +
腳本是:
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")
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;
}
我已經連接了調試Python的過程中,我看到薩德異常升高返回0執行。引發的異常是:
調試斷言失敗! ..... _BLOCK_TYPE_IS_VALID(pHead-> nBlockUse)...
任何想法?謝謝。
wath是相當於std :: string在python中嗎? – gpiscite
不要以爲有ctypes。我個人不知道,但看看SWIG是否可以處理這個問題。 – rhody