Error with Matlab Engine/Data API for C++ (EDIT: Resolved)

12 ビュー (過去 30 日間)
Gavin McGee
Gavin McGee 2019 年 5 月 23 日
編集済み: Alexander van Zyl 2020 年 10 月 20 日
I am attempting to write some simple test programs using Matlab Engine for C++. I was able to get it working fine yesterday, until I updated from R2019a Update 1 to R2019a Update 2. Ever since then, the files for Matlab Engine for C++ have been causing compiler errors. Whenever I write a program that includes the files "MatlabEngine.hpp" and/or "MatlabDataArray.hpp", I get the following errors:
Error C2760 syntax error: unexpected token 'identifier', expected 'expression' C:\Program Files\MATLAB\R2019a\extern\include\MatlabDataArray\ArrayFactory.hpp 164
Error C2760 syntax error: unexpected token 'identifier', expected 'expression' C:\Program Files\MATLAB\R2019a\extern\include\MatlabDataArray\ArrayFactory.hpp 219
Error C2760 syntax error: unexpected token 'identifier', expected 'expression' C:\Program Files\MATLAB\R2019a\extern\include\MatlabDataArray\ArrayFactory.hpp 552
Error C2760 syntax error: unexpected token 'identifier', expected 'expression' C:\Program Files\MATLAB\R2019a\extern\include\MatlabDataArray\ArrayFactory.hpp 624
I am compiling using Visual Studio 2019, and am using a trial license version of Matlab. I am compiling and running on a Windows 10 computer. These errors occur even with this simple test program:
#include <iostream>
#include "MatlabEngine.hpp"
#include "MatlabDataArray.hpp"
int main(){
std::cout << "Hello World!\n\r";
return 0;
}
I have all the necessary folders/libraries in my path and project settings. It is always the same 4 errors. Does anyone have any idea what might be causing this? I have tried re-installing Matlab and Visual Studio, but nothing seems to work.
EDIT :
Found the problem. I changed the setting Project->Properties->C/C++->Language->Conformance Mode from "Yes" to "No", and that fixed the error.
  2 件のコメント
Tom Heitmann
Tom Heitmann 2020 年 2 月 5 日
same for me in R2019b! Thanks a lot!
Alan Frankel
Alan Frankel 2020 年 6 月 17 日
This should only happen with Visual Studio 2019 Community Edition, not Professional, and it should not happen with earlier versions of Visual Studio. Could you please confirm that you are using Visual Studio 2019 Community Edition?

サインインしてコメントする。

回答 (1 件)

Alan Frankel
Alan Frankel 2020 年 6 月 17 日
編集済み: Alan Frankel 2020 年 6 月 17 日
Setting Conformance mode to No will work around a compiler build issue seen in VS 2019 Community Edition with MATLAB R2018b through R2020a, in which several lines in extern\include\MatlabDataArray\ArrayFactory.hpp will trigger error C2760. Note that with mbuild, Conformance mode is set to No by default. Alternatively, particularly if Conformance mode = Yes is desired, the error can be fixed by inserting the keyword typename before instances of the strings impl::ArrayFactoryImpl and impl::ArrayImpl on those lines. The compiler error is not seen in VS 2019 Professional, VS 2017 Professional, or VS 2017 Community Edition. See also How do I build a driver application for a C++ MATLAB Data API Shared Library using Microsoft Visual Studio?
  4 件のコメント
Alan Frankel
Alan Frankel 2020 年 9 月 8 日
Gavin was describing a compiler issue. You are describing a different issue, which occurs at runtime. Have you seen this post?
Alexander van Zyl
Alexander van Zyl 2020 年 10 月 20 日
編集済み: Alexander van Zyl 2020 年 10 月 20 日
I am having the same issue as @Jacob and I have not been able to fix it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeC Shared Library Integration についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by