matlab可以调用c++的DLL吗?

我可以切确的说,支持调用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)
 {



}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值