mclcppclass.h error

4 visualizaciones (últimos 30 días)
Martin Alejandro Gorosito
Martin Alejandro Gorosito el 23 de Mayo de 2020
Respondida: Sindhu Karri el 26 de Mayo de 2020
I built a simple shared library from a MATLAB function following this tutorial .
My function in MATLAB is:
function y = counting_characters(x)
y = strlength(x);
end
After many attempts to make VS code to run it, fighting for it to detect the libraries, I went back to my old Dev C++, set the paths there, and it detected them. Yet, when I compile my program, the mclcppclass.h file (automatically generated) opens and gives these errors:
C:\Program Files\MATLAB\MATLAB Runtime\v98\extern\include\mclcppclass.h In constructor 'mwArray::mwArray(const mxChar*, MWObjectType)':
115 14 C:\Program Files\MATLAB\MATLAB Runtime\v98\extern\include\mclcppclass.h [Error] 'status' does not name a type
116 13 C:\Program Files\MATLAB\MATLAB Runtime\v98\extern\include\mclcppclass.h [Error] 'status' was not declared in this scope
C:\Program Files\MATLAB\MATLAB Runtime\v98\extern\include\mclcppclass.h In member function 'void mwArray::SetStringData(const std::vector<std::basic_string<short unsigned int> >&)':
410 14 C:\Program Files\MATLAB\MATLAB Runtime\v98\extern\include\mclcppclass.h [Error] 'size' does not name a type
411 13 C:\Program Files\MATLAB\MATLAB Runtime\v98\extern\include\mclcppclass.h [Error] 'size' was not declared in this scope
413 43 C:\Program Files\MATLAB\MATLAB Runtime\v98\extern\include\mclcppclass.h [Error] 'size' was not declared in this scope
C:\Program Files\MATLAB\MATLAB Runtime\v98\extern\include\mclcppclass.h In member function 'std::vector<std::basic_string<short unsigned int> > mwArray::GetStringData() const':
1236 81 C:\Program Files\MATLAB\MATLAB Runtime\v98\extern\include\mclcppclass.h [Error] 'nullptr' was not declared in this scope
C:\Program Files\MATLAB\MATLAB Runtime\v98\extern\include\mclcppclass.h In member function 'const mxChar* mwArray::GetStringElement(mwSize) const':
1247 29 C:\Program Files\MATLAB\MATLAB Runtime\v98\extern\include\mclcppclass.h [Error] 'nullptr' was not declared in this scope
Below, I provide my C++ code (it is very basic)
#include <iostream>
#include "libcountingcharacters.h"
int ac;
const char av[]= "Hello World";
int main()
{
// Initialize the MATLAB Compiler Runtime global state
if (!mclInitializeApplication(NULL,0))
{
std::cerr << "Could not initialize the application properly."
<< std::endl;
return -1;
}
// Initialize the Counting characters library
if( !libcountingcharactersInitialize() )
{
std::cerr << "Could not initialize the library properly."
<< std::endl;
return -1;
}
// Must declare all MATLAB data types after initializing the
// application and the library, or their constructors will fail.x
mwArray text(av[2]);
mwArray result;
counting_characters(1,result,text);
std::cout << result << std::endl;
// Shut down the library and the application global state.
libcountingcharactersTerminate();
mclTerminateApplication();
}
What am I missing here? I dont have a programming background so please try to use simple explanations...

Respuestas (1)

Sindhu Karri
Sindhu Karri el 26 de Mayo de 2020
Hii,
You can try modifying these line in your code as:
const char *av= "Hello World";
instead of
const char av[]= "Hello World";
also
mwArray text(av);
instead of
mwArray text(av[2]);
Note: Have successfully compiled in Microsoft Visual C++ 2017
Below attached link might be useful when using mwArray

Categorías

Más información sobre Deploy to C++ Applications Using mwArray API (C++03) en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by