当前位置:网站首页>用matlab调用vs2015来编译vs工程
用matlab调用vs2015来编译vs工程
2022-07-02 22:09:00 【Clouds_Above】
用matlab调用vs2015来编译vs工程
一、背景:
在测试仿真模型的时候需要自动化批量测试。而模型的输入是一个加密的任务文件。这个文件是大佬用cpp写的,需要用vs编译。
二、目的:
因此我想要实现的功能就是:
- 用matlab脚本设置不同任务信息,自动生成不同的cpp程序。
- 调用vs编译,生成加密的任务文件
- 调用simulink运行模型,仿真任务执行情况
- 对比任务执行情况和m脚本设置时预计的情况
这样就可以在matlab环境下实现全流程仿真测试。
三、实现
基本实现思路是用matlab脚本中用dos命令实现对vs的调用。
(这种方法其实可以实现对所有软件的调用)
3.1. 配置环境
首先需要添加环境变量,把需要的头文件include和库文件lib加进去
新建一个变量,名为include(不区分大小写),然后变量值有如下两个:
D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
类似地,新建一个变量,名为lib(不区分大小写),然后变量值有如下两个:
D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib
其他的如果有必要,就也加上:
在include下添加:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt
在lib下添加:
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x86
为了能在命令行使用devenv命令,还需要在path下添加:
D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
D:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
3.2. 自动编译的dos命令
添加完这些环境之后,如果想编译普通的cpp程序,可以在命令行使用命令:
cl xxx_main.cpp
但是编译工程还是不行,需要用到下面的命令:
devenv "TestProg.sln" /Rebuild Debug /project "xxx\TestProg.vcxproj"
会编译出可执行程序,然后再运行可执行程序即可
3.3. matlab脚本
这部分值得展开的,
需要注意的是,如果想在某个目录下执行什么dos命令
需要直接cd(‘xxxx’)进去。
而不能 dos(‘cd xxxxxx’)
把上面在命令行执行的命令,在matlab脚本里用dos调用即可
如:
dos('devenv "TestProg.sln" /Rebuild Debug /project "xxx\TestProg.vcxproj"')
边栏推荐
- 严守工期,确保质量,这家AI数据标注公司做到了!
- boot actuator - prometheus使用
- Jerry's built-in short press and long press, no matter how long it is, it is a short press [chapter]
- stop slave卡住--事务的事件没有复制完整
- Jatpack------LiveData
- Niuke network: maximum submatrix
- 【洛谷P1541】乌龟棋【DP】
- 最小生成树 Minimum Spanning Tree
- Jerry's prototype has no touch, and the reinstallation becomes normal after dismantling [chapter]
- Gas station [problem analysis - > problem conversion - > greed]
猜你喜欢

Go language sqlx library operation SQLite3 database addition, deletion, modification and query

【板栗糖GIS】arcscene—如何做出有高度的高程图

Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises

Local dealers play the community group purchase mode and share millions of operations

泛型与反射,看这篇就够了

Hanging mirror security won four global infosec awards on rsac2022

手写ORM(对象关系映射)增删改查
![[chestnut sugar GIS] ArcMap - why should the tick of classic capture be removed when using custom capture?](/img/b5/e746dd115995e82c93f667c58a601c.png)
[chestnut sugar GIS] ArcMap - why should the tick of classic capture be removed when using custom capture?

性能优化----严苛模式

odoo13搭建医院HRP环境(详细步骤)
随机推荐
psnr,ssim,rmse三个指标的定量分析
Go language sqlx library operation SQLite3 database addition, deletion, modification and query
Go 4 modes Singleton
Dahua cloud native load balancing article - the passenger flow of small restaurants has increased
[leetcode] there are duplicate elements [217]
【喜欢的诗词】好了歌
Lambda expression: an article takes you through
损失函数~
位的高阶运算
P7072 [csp-j2020] live broadcast Award
手写ORM(对象关系映射)增删改查
Jatpack------LiveData
[LeetCode] 反转字符串中的单词 III【557】
LC173. 二叉搜索树迭代器
数组进阶提高
How does Jerry test the wrong touch rate of keys [chapter]
MySQL查询附近的数据.并按距离进行排序.
Pytorch training CPU usage continues to grow (Bug)
Gas station [problem analysis - > problem conversion - > greed]
MySQL queries nearby data And sort by distance