问小白 wenxiaobai
资讯
历史
科技
环境与自然
成长
游戏
财经
文学与艺术
美食
健康
家居
文化
情感
汽车
三农
军事
旅行
运动
教育
生活
星座命理

Matlab调用C++生成的Dll动态链接库

创作时间:
作者:
@小白创作中心

Matlab调用C++生成的Dll动态链接库

引用
CSDN
1.
https://blog.csdn.net/qq_53018083/article/details/139838974

本文将介绍如何在Visual Studio 2019和Matlab 2019环境下,创建一个C++项目并生成Dll,以及如何在Matlab中调用该Dll。

1.软件版本

  • Visual Studio 2019
  • Matlab 2019

2.C++生成Dll

1.创建一个空项目

2.新建一个SimDll.h和SimDll.cpp文件

//SimDll.h
#pragma once
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
    __declspec(dllexport)int add(int a, int b);
    __declspec(dllexport)double multiply(double a, double b);
#ifdef __cplusplus
}
#endif // __cplusplus
// SimDll.cpp
#include<iostream>
#include"SimDll.h"
int add(int a, int b) 
{
    return a + b;
}
double multiply(double a, double b) 
{
    return a * b;
}

3.配置工程属性

1.选择项目-Si

本文原文来自CSDN

© 2023 北京元石科技有限公司 ◎ 京公网安备 11010802042949号