我正在努力在Matlab(2019a)中导入C ++(2017)dlls。
尤其是,由于我不熟悉C ++,因此我尝试创建在https://github.com/MicrosoftDocs/cpp-docs/blob/master/docs/build/walkthrough-creating-and-using-a-dynamic-link-library-cpp.md中定义的MathLibrary。 我根据指南创建了该库,并同时编译了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
,然后像这样继续进行,但出现许多字符错误。 我的代码有什么问题?我该如何解决?