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

18 visualizaciones (últimos 30 días)
Gavin McGee
Gavin McGee el 23 de Mayo de 2019
Editada: Alexander van Zyl el 20 de Oct. de 2020
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 comentarios
Tom Heitmann
Tom Heitmann el 5 de Feb. de 2020
same for me in R2019b! Thanks a lot!
Alan Frankel
Alan Frankel el 17 de Jun. de 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?

Iniciar sesión para comentar.

Respuestas (1)

Alan Frankel
Alan Frankel el 17 de Jun. de 2020
Editada: Alan Frankel el 17 de Jun. de 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 comentarios
Alan Frankel
Alan Frankel el 8 de Sept. de 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 el 20 de Oct. de 2020
Editada: Alexander van Zyl el 20 de Oct. de 2020
I am having the same issue as @Jacob and I have not been able to fix it.

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by