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

20 visualizzazioni (ultimi 30 giorni)
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 Commenti
Alan Frankel
Alan Frankel il 17 Giu 2020
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?

Accedi per commentare.

Risposte (1)

Alan Frankel
Alan Frankel il 17 Giu 2020
Modificato: Alan Frankel il 17 Giu 2020
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 Commenti
Alan Frankel
Alan Frankel il 8 Set 2020
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 il 20 Ott 2020
Modificato: Alexander van Zyl il 20 Ott 2020
I am having the same issue as @Jacob and I have not been able to fix it.

Accedi per commentare.

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by