我可以切确的说,支持调用c++生成的DLL,我亲测,以下是官方原文:
The shared library interface does not support C++ classes or overloaded functions elements. However, if you have source code for the library, you can apply one of the following strategies to load a C++ library using loadlibrary. After editing the source code, rebuild the library. 有人网上说matlab不能够调用c++,不支持多态性和重载,从这里官方原文可以看出,你需要调用的c++函数必须写成c的形式,就可以加载的,后来我确实写成c的形式了,可以调用。如果你调用c++的dll,经常系统崩溃,那么你的程序肯定有问题。
头文件是这样定义:
#ifdef __cplusplus
extern "C" {
#endif
void addMixedTypes(
short x,
int y,
double z
);
/* other prototypes may be here */
#ifdef __cplusplus
}
#endif
注意不要在头文件写成这种形式:
extern "C" void addMixedTypes(short x,int y,double z);
在cpp文件代码如下:
extern "C" unsigned int __declspec(dllexport)__stdcall void addMixedTypes( short x int y,double z)
{
}