Effacer les filtres
Effacer les filtres

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

14 vues (au cours des 30 derniers jours)
Gavin McGee
Gavin McGee le 23 Mai 2019
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 commentaires
Tom Heitmann
Tom Heitmann le 5 Fév 2020
same for me in R2019b! Thanks a lot!
Alan Frankel
Alan Frankel le 17 Juin 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?

Connectez-vous pour commenter.

Réponses (1)

Alan Frankel
Alan Frankel le 17 Juin 2020
Modifié(e) : Alan Frankel le 17 Juin 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 commentaires
Alan Frankel
Alan Frankel le 8 Sep 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 le 20 Oct 2020
Modifié(e) : Alexander van Zyl le 20 Oct 2020
I am having the same issue as @Jacob and I have not been able to fix it.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by