c++ - 如何在 Matlab 中导入 C++ dll
问题描述
我正在努力在 Matlab (2019a) 中导入 C++ (2017) dll。
特别是,由于我不熟悉 C++,因此我尝试创建 https://github.com/MicrosoftDocs/cpp-docs/blob/master/docs/build/walkthrough-creating-and-using- 中定义的MathLibrary a-动态链接库-cpp.md。我根据指南创建了库,编译了 Debug 和 Release (x86),并且使用描述的 MathClient 导入工作正常。
但是,我尝试在 Matlab 中导入库(在将所需文件夹添加到当前路径之后):
if libisloaded('MathLibrary') == 0
handle = loadlibrary('MathLibrary.dll','MathLibrary.h');
end
它会引发大量错误:
Warning: Message from C preprocessor:
cl : command line warning D9027: source file 'C:\Users\miche\source\repos\MathLibrary\Release\MathLibrary.lib' ignored
cl : command line warning D9021 : no operation performed
> In loadlibrary
Error loading library intermediate output follows.
The actual error is at the end of this output.
*********
Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by <-- HERE in m/struct([^;,{(]*){ <-- HERE (.*?)\}([^;])*;/ at D:\Program Files\MATLAB\R2019a\toolbox\matlab\general\private\prototypes.pl line 912.
Warning no reference to header 'MathLibrary' added with addheader was found in source.
*********
Error using loadlibrary
Building MathLibrary_thunk_pcwin64 failed. Compiler output is:
cl -I"D:\Program Files\MATLAB\R2019a\extern\include" /Zp8 /W3
/nologo -I"D:\Program Files\MATLAB\R2019a\bin"
-I"C:\Users\user\source\repos\MathLibrary\Release"
"MathLibrary_thunk_pcwin64.c" -LD
-Fe"MathLibrary_thunk_pcwin64.dll"
MathLibrary_thunk_pcwin64.c
C:\Users\miche\source\repos\MathLibrary\Release\MathLibrary.lib(1):
error C2059: syntax error: '!'
C:\Users\miche\source\repos\MathLibrary\Release\MathLibrary.lib(2):
error C2018: character '0x60' unknown
然后就这样继续下去,有很多字符错误。我的代码有什么问题?我该如何解决这个问题?
解决方案
推荐阅读
- sql - 快速计算十分位数
- python - 使用 subprocess.check_output 运行 flake8
- express - 猫鼬代码仅在我发出 2 个 http 请求时才有效
- google-cloud-platform - 为什么 du 没有为添加到 GCP 中的实例的磁盘返回正确的编号
- java - itext PDF 5版本如何将垂直行分隔符添加到具有2个单元格的表格中
- charts - 工具提示在 Google 散点图中不起作用
- android - 无法为颤振应用程序构建连接插件
- java - Junit 测试:为 jpa 存储库引发 NullPointerException
- java - 在列表中存储带有浮点数的列表
- git - 使用 IntelliJ IDEA 从 git 存储库恢复文件