Python调用C++DLL函数出错String类型问题

 

调用c++ 函数原型以下,一直失败,请个日志断点发现 参数未能正确解析。python

int EXPORT  init_ner(string cfg_path);
typedef int (*Proc_init_ner)(string cfg_path);

int EXPORT  fini_ner();
typedef int (*Proc_fini_ner)();


string EXPORT process(string input_jsn_str);
typedef string (*Proc_process)(string input_jsn_str);

 改动C++ 代码以下:c++

int EXPORT  init_ner(const char* cfg_path);
typedef int (*Proc_init_ner)(const char* cfg_path);

int EXPORT  fini_ner();
typedef int (*Proc_fini_ner)();


string EXPORT process(const char* input_jsn_str);
typedef string (*Proc_process)(const char* input_jsn_str);

 python以下调用 就能够成功了。函数

dll = windll.LoadLibrary("NER.dll")

dll.init_ner("./engine_cfg/ner.cfg")
相关文章
相关标签/搜索